/*
 * Sukud design system - shells
 * App shell (sidebar, top bar, content, phone bottom bar), auth shell and
 * page header.
 *
 * Breakpoints: phone < 768 (bottom bar, drawer sidebar), tablet 768-1279
 * (icon rail), desktop >= 1280 (full sidebar, collapsible to the rail).
 */

/* ======================================================================
 * App shell
 * ====================================================================== */
.sk-app { display: flex; min-height: 100dvh; }

.sk-sidebar {
  position: sticky;
  top: 0;
  z-index: var(--sk-z-nav);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: var(--sk-sidebar-w);
  height: 100dvh;
  padding: 14px 12px 12px;
  background: var(--sk-canvas);
  overflow: hidden;
  transition: width 460ms var(--sk-ease-glide);
}
/* The brand and the foot never shrink: only the links between them scroll,
 * so the logo is never clipped and the list keeps the same top on every page. */
.sk-sidebar__brand { display: flex; flex-shrink: 0; align-items: center; gap: 10px; height: 40px; padding: 0 7px; margin-bottom: 14px; overflow: hidden; }
.sk-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--sk-fg); text-decoration: none; min-width: 0; }
.sk-brand__mark {
  display: grid; place-items: center;
  flex-shrink: 0;
  width: 34px; height: 34px;
  transition: transform var(--sk-dur-slow) var(--sk-ease-spring);
}
.sk-brand:hover .sk-brand__mark { transform: rotate(-8deg) scale(1.05); }
/* The logo itself: dark on light surfaces, white on dark ones. */
.sk-brand__logo { width: 32px; height: 32px; object-fit: contain; }
.sk-brand__logo--dark, [data-theme="dark"] .sk-brand__logo--light { display: none; }
[data-theme="dark"] .sk-brand__logo--dark { display: block; }
.sk-brand__word { font-family: var(--sk-font-display); font-size: 1.3rem; font-weight: var(--sk-weight-black); letter-spacing: -0.035em; white-space: nowrap; }
.sk-sidebar__collapse { margin-inline-start: auto; }
.sk-sidebar__close { display: none; }
.sk-sidebar__scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; margin: 0 -12px; padding: 2px 12px 12px; scrollbar-width: none; }
.sk-sidebar__scroll::-webkit-scrollbar { display: none; }
.sk-sidebar__foot { display: flex; flex-shrink: 0; flex-direction: column; gap: 8px; padding-top: 10px; border-top: 1px solid var(--sk-border-subtle); }
.sk-sidebar__user {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px;
  border-radius: 12px;
  min-width: 0;
  text-align: start;
  width: 100%;
  transition: background-color var(--sk-dur-fast);
}
.sk-sidebar__user:hover { background: var(--sk-surface-hover); }

.sk-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.sk-content {
  flex: 1 1 auto;
  width: 100%;
  max-width: calc(var(--sk-content-max) + var(--sk-gutter) * 2);
  margin-inline: auto;
  padding: 8px var(--sk-gutter) 48px;
  container-type: inline-size;
  container-name: content;
}
.sk-content--wide { max-width: none; }
.sk-content--narrow { max-width: calc(760px + var(--sk-gutter) * 2); }

/* Collapsed rail. sukud-ui.js sets .is-rail on tablets by default and on
 * desktops by choice; phones never get it (they use the drawer).
 *
 * Nothing switches to display:none, so the change can be animated: the
 * width glides, icons keep their x position (items pad the icon to the
 * rail's centre line), labels fade out first and are clipped as the width
 * closes, section titles fold away, and items grow into 1:1 tiles. On
 * expand the order reverses: width first, then labels fade back in. */
@media (min-width: 768px) {
  .sk-app.is-rail .sk-sidebar { width: var(--sk-rail-w); }
  .sk-app.is-shell-instant .sk-sidebar, .sk-app.is-shell-instant .sk-sidebar * { transition: none !important; }

  .sk-sidebar :is(.sk-brand__word, .sk-nav__label, .sk-nav__chevron, .sk-nav__item .sk-badge, .sk-sidebar__foot .sk-person__text) {
    transition: opacity 220ms var(--sk-ease-out) 140ms, transform 360ms var(--sk-ease-glide) 100ms;
  }
  .sk-app.is-rail .sk-sidebar :is(.sk-brand__word, .sk-nav__label, .sk-nav__chevron, .sk-nav__item .sk-badge, .sk-sidebar__foot .sk-person__text) {
    opacity: 0;
    transform: translateX(-8px);
    pointer-events: none;
    transition: opacity 120ms var(--sk-ease-in) 0ms, transform 200ms var(--sk-ease-in) 0ms;
  }

  .sk-app.is-rail .sk-nav__item { min-height: 48px; }
  .sk-app.is-rail .sk-sidebar__brand { padding-inline: 7px; }
  .sk-app.is-rail .sk-sidebar__user { padding-inline: 6px; }

  /* Section titles fold to nothing; a hairline marks the gap between groups. */
  .sk-nav__title { max-height: 32px; overflow: hidden; transition: max-height 380ms var(--sk-ease-glide), opacity 200ms var(--sk-ease-out) 140ms, padding 380ms var(--sk-ease-glide); }
  .sk-app.is-rail .sk-nav__title { max-height: 0; opacity: 0; padding-block: 0; transition: max-height 380ms var(--sk-ease-glide), opacity 100ms var(--sk-ease-in), padding 380ms var(--sk-ease-glide); }
  .sk-nav__section + .sk-nav__section { position: relative; }
  .sk-nav__section + .sk-nav__section::before {
    content: ''; position: absolute; left: 12px; right: 12px; top: -8px; height: 1px;
    background: var(--sk-border-subtle); opacity: 0; transition: opacity 200ms var(--sk-ease-out);
  }
  .sk-app.is-rail .sk-nav__section + .sk-nav__section::before { opacity: 1; transition-delay: 180ms; }

  /* Unread counts shrink into a dot on the icon's corner instead of hiding. */
  .sk-nav__item .sk-count { transition: transform 360ms var(--sk-ease-spring), top 360ms var(--sk-ease-glide), right 360ms var(--sk-ease-glide); }
  .sk-app.is-rail .sk-nav__item .sk-count { position: absolute; top: 7px; right: 7px; min-width: 16px; height: 16px; padding: 0 4px; font-size: 9.5px; box-shadow: 0 0 0 2px var(--sk-canvas); }

  /* Nested pages fold away; the group's own icon stays. */
  .sk-nav__sub { transition: opacity 200ms var(--sk-ease-out); }
  .sk-app.is-rail .sk-nav__sub { display: none; }

  .sk-sidebar__foot .sk-theme-picker { max-height: 60px; overflow: hidden; transition: max-height 380ms var(--sk-ease-glide), opacity 200ms var(--sk-ease-out) 140ms; }
  .sk-app.is-rail .sk-sidebar__foot .sk-theme-picker { max-height: 0; opacity: 0; pointer-events: none; transition: max-height 380ms var(--sk-ease-glide), opacity 100ms var(--sk-ease-in); }
}

/* Phones: sidebar becomes an off-canvas drawer; bottom bar takes over. */
.sk-app__menu-btn { display: none; }
.sk-sidebar-scrim { display: none; }
@media (max-width: 767.98px) {
  .sk-sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: var(--sk-z-modal);
    width: 100%;
    height: 100dvh;
    padding-top: max(14px, env(safe-area-inset-top));
    padding-bottom: max(12px, var(--sk-safe-bottom));
    background: var(--sk-canvas);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform var(--sk-dur-slow) var(--sk-ease-out), visibility 0s linear var(--sk-dur-slow);
  }
  .sk-sidebar__close { display: inline-flex; margin-inline-start: auto; }
  .sk-app.is-nav-open .sk-sidebar { transform: none; visibility: visible; transition-delay: 0s; }
  .sk-sidebar-scrim {
    display: block;
    position: fixed; inset: 0;
    z-index: calc(var(--sk-z-modal) - 1);
    background: var(--sk-scrim);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--sk-dur-slow) var(--sk-ease-out);
  }
  .sk-app.is-nav-open .sk-sidebar-scrim { opacity: 1; pointer-events: auto; }
  .sk-app__menu-btn { display: inline-flex; }
  .sk-app__rail-btn { display: none; }
  .sk-sidebar__collapse { display: none; }
  .sk-app.has-bottomnav .sk-content { padding-bottom: calc(var(--sk-bottomnav-h) + var(--sk-safe-bottom) + 36px); }
  .sk-app.has-bottomnav { --sk-toaster-offset: calc(var(--sk-bottomnav-h) + 10px); }
  /* Sticky action bars ride just above the floating bottom bar. */
  .sk-app.has-bottomnav .sk-form-actions--sticky { bottom: calc(var(--sk-bottomnav-h) + var(--sk-safe-bottom) + 10px); border-radius: 18px; margin-inline: 0; padding: 10px; border: 1px solid var(--sk-border-subtle); box-shadow: var(--sk-shadow-md); }
  .sk-topbar__title { font-size: var(--sk-text-lg); }
}
@media (min-width: 768px) { .sk-bottomnav { display: none; } }

/* ======================================================================
 * Page header
 * ====================================================================== */
.sk-page-header { display: flex; flex-direction: column; gap: 14px; padding: 4px 0 6px; min-width: 0; }
.sk-page-header__row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.sk-page-header__titles { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1 1 320px; }
.sk-page-header__title-row { display: flex; align-items: center; gap: 12px; min-width: 0; flex-wrap: wrap; }
.sk-page-header__title { font-family: var(--sk-font-display); font-size: var(--sk-display-md); line-height: var(--sk-leading-display-md); font-weight: var(--sk-weight-bold); letter-spacing: var(--sk-tracking-display); text-wrap: balance; }
.sk-page-header__icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--sk-radius-full); background: var(--t-soft); color: var(--t-text); flex-shrink: 0; }
.sk-page-header__icon .sk-icon { width: 20px; height: 20px; }
.sk-page-header__desc { font-size: var(--sk-text-lg); line-height: 1.5; color: var(--sk-fg-muted); max-width: 64ch; text-wrap: pretty; }
.sk-page-header__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-inline-start: auto; }
.sk-page-header__meta { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; font-size: var(--sk-text-sm); color: var(--sk-fg-muted); }
.sk-page-header__meta > span { display: inline-flex; align-items: center; gap: 5px; }
.sk-page-header__meta .sk-icon { width: 15px; height: 15px; }
@container (max-width: 560px) {
  .sk-page-header__title { font-size: var(--sk-display-sm); line-height: var(--sk-leading-display-sm); }
  .sk-page-header__desc { font-size: var(--sk-text-md); }
  .sk-page-header__actions { width: 100%; }
  .sk-page-header__actions > .sk-btn { flex: 1 1 auto; }
}

/* ======================================================================
 * Auth shell (split: brand panel + form)
 * ====================================================================== */
.sk-auth { display: grid; min-height: 100dvh; grid-template-columns: 1fr; background: var(--sk-surface); }
.sk-auth__main { display: flex; flex-direction: column; min-width: 0; padding: 20px var(--sk-gutter) 28px; }
.sk-auth__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.sk-auth__body { flex: 1; display: flex; align-items: center; justify-content: center; padding-block: 28px; }
.sk-auth__card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 24px; animation: sk-rise var(--sk-dur-slower) var(--sk-ease-out); }
.sk-auth__card--wide { max-width: 560px; }
.sk-auth__head { display: flex; flex-direction: column; gap: 8px; }
.sk-auth__title { font-family: var(--sk-font-display); font-size: var(--sk-display-md); line-height: 1.1; font-weight: var(--sk-weight-black); letter-spacing: -0.03em; }
.sk-auth__sub { color: var(--sk-fg-muted); font-size: var(--sk-text-lg); line-height: 1.5; }
.sk-auth__foot { text-align: center; color: var(--sk-fg-muted); font-size: var(--sk-text-sm); }
/* Sign up: what you are joining, then about you */
.sk-signup__systems { --min: 100%; gap: 8px; }
.sk-signup__systems .sk-choice { padding: 14px 16px; }
.sk-signup__systems .sk-choice__head .sk-badge { margin-inline-start: 2px; }
.sk-signup__back {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 14px 10px 10px; border: 1px solid var(--sk-border-subtle); border-radius: 14px;
  background: var(--sk-surface-sunken); color: var(--sk-fg); font: inherit; text-align: start; cursor: pointer;
  transition: background-color var(--sk-dur-fast), border-color var(--sk-dur-fast);
}
.sk-signup__back:hover { border-color: var(--sk-border); background: var(--sk-surface-hover); }
.sk-signup__back-icon { display: grid; place-items: center; flex-shrink: 0; width: 34px; height: 34px; border-radius: 10px; background: var(--sk-surface); box-shadow: var(--sk-shadow-xs); }
.sk-signup__back small { display: block; font-size: var(--sk-text-2xs); font-weight: var(--sk-weight-bold); letter-spacing: var(--sk-tracking-caps); text-transform: uppercase; color: var(--sk-fg-subtle); }
.sk-signup__back b { font-size: var(--sk-text-sm); font-weight: var(--sk-weight-semibold); }
.sk-signup__change { margin-inline-start: auto; font-size: var(--sk-text-sm); font-weight: var(--sk-weight-semibold); color: var(--sk-brand-11); }
/* Applications: one block per child */
.sk-child { display: flex; flex-direction: column; gap: 14px; min-width: 0; margin: 0; padding: 14px 16px 16px; border: 1px solid var(--sk-border-subtle); border-radius: 18px; background: var(--sk-surface); }
.sk-child__title { display: flex; align-items: center; gap: 10px; padding: 0 4px; font-size: var(--sk-text-sm); font-weight: var(--sk-weight-semibold); }
.sk-auth__legal { text-align: center; font-size: var(--sk-text-xs); color: var(--sk-fg-subtle); }

/* ======================================================================
 * Focus shell (ui/layouts/focus.html): one task, full screen
 * ====================================================================== */
.sk-focus { min-height: 100dvh; display: flex; flex-direction: column; background: var(--sk-canvas); }
.sk-focus__bar {
  position: sticky; top: 0; z-index: var(--sk-z-header);
  display: flex; align-items: center; gap: 14px;
  min-height: 60px; padding: max(8px, env(safe-area-inset-top)) var(--sk-gutter) 8px;
  background: var(--sk-canvas);
  background: color-mix(in srgb, var(--sk-canvas) 90%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.sk-focus__start, .sk-focus__end { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.sk-focus__progress { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.sk-focus__main { flex: 1 0 auto; width: 100%; max-width: calc(700px + var(--sk-gutter) * 2); margin: 0 auto; padding: 12px var(--sk-gutter) 40px; display: flex; flex-direction: column; gap: 22px; animation: sk-rise var(--sk-dur-slow) var(--sk-ease-out); }
.sk-focus__foot {
  position: sticky; bottom: 0; z-index: var(--sk-z-sticky);
  padding: 12px var(--sk-gutter) calc(12px + var(--sk-safe-bottom));
  border-top: 1px solid var(--sk-border-subtle);
  background: var(--sk-surface);
  transition: background-color var(--sk-dur-base), border-color var(--sk-dur-base);
}
.sk-focus__foot.is-good { background: var(--sk-green-3); border-color: var(--sk-green-6); }
.sk-focus__foot.is-wait { background: var(--sk-amber-3); border-color: var(--sk-amber-6); }
.sk-focus__foot-in { max-width: 700px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sk-focus__title { font-size: var(--sk-text-xs); font-weight: var(--sk-weight-semibold); color: var(--sk-fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sk-focus .sk-net { top: 64px; }

/* Quiz question (inside the focus shell) */
.sk-question { font-family: var(--sk-font-display); font-size: clamp(1.35rem, 1.05rem + 1.3vw, 1.95rem); font-weight: var(--sk-weight-bold); letter-spacing: -0.025em; line-height: 1.22; text-wrap: pretty; overflow-wrap: anywhere; }
