/* ---------------------------------------------------------------------
   Earth-tone accents on a neutral night ground: who gets which tone, plus
   atmosphere and motion. The ground, glow, grain and stars are neutral, so
   color comes only from the pieces below.

   The tones are defined in the theme block of path-dashboard.css. Here each
   piece of the workspace is given one, by role:
     wheat  primary actions, "comfortable"
     sage   links, growth, "practising", Mr. Buttons' room
     oak    people: learner tags, learner cards, the Learners area
     clay   "just starting" and suggestions
     stone  borders and secondary text
   Each area also owns a tone (--page) for its nav item, selected tabs, small
   labels, title marker and hovers: Path starlight, Learning Record sage,
   Lesson Plan clay, Library river, Learners oak, Account dusk.

   Loaded last; screen only, so nothing here reaches print.
   --------------------------------------------------------------------- */
@media screen {
  /* ---------- Each area owns a tone ---------- */
  /* The Path is the night sky, so its tone is starlight; wheat is left to mean
     "act" and "comfortable". Oak is only ever people. */
  body[data-workspace-view] { --page: var(--pw-star); --page-rgb: 195, 207, 232; }
  body[data-workspace-view="progress"], body[data-workspace-view="parent-note"] { --page: var(--pw-sage); --page-rgb: 160, 188, 132; }
  body[data-workspace-view="build"], body[data-workspace-view="saved"] { --page: var(--pw-clay); --page-rgb: 213, 141, 105; }
  body[data-workspace-view="schoolwork"] { --page: var(--pw-river); --page-rgb: 112, 186, 174; }
  body[data-workspace-view="learners"] { --page: var(--pw-oak); --page-rgb: 201, 160, 116; }
  body[data-workspace-view="account"], body[data-workspace-view="admin"] { --page: var(--pw-dusk); --page-rgb: 127, 172, 203; }

  /* ---------- Atmosphere: stars, moonlight, fine grain (all neutral) ---------- */
  body[data-workspace-view]::before {
    background-image:
      radial-gradient(circle at 15% 20%, rgba(240, 244, 252, .6) 0 1px, transparent 1.6px),
      radial-gradient(circle at 73% 12%, rgba(206, 220, 246, .55) 0 1px, transparent 1.5px),
      radial-gradient(circle at 82% 72%, rgba(240, 244, 252, .45) 0 1px, transparent 1.6px),
      radial-gradient(circle at 37% 81%, rgba(222, 218, 240, .45) 0 1px, transparent 1.5px);
    animation: pw-twinkle 11s ease-in-out infinite alternate;
  }
  body[data-workspace-view]::after {
    background-image:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .94 0 0 0 0 .96 0 0 0 0 1 0 0 0 .045 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23g)'/%3E%3C/svg%3E"),
      radial-gradient(62rem 42rem at 90% -8%, rgba(126, 146, 182, .075), transparent 70%),
      radial-gradient(46rem 34rem at -6% 62%, rgba(126, 146, 182, .035), transparent 70%);
    background-size: 200px 200px, auto, auto;
    background-repeat: repeat, no-repeat, no-repeat;
    background-position: 0 0, center, center;
    opacity: 1;
  }
  /* Topographic contours drift slowly behind content pages: paths across
     terrain under the same night sky as the map. */
  body[data-workspace-view]:not([data-workspace-view="journey"]) #lesson-workspace-app::before {
    content: ''; position: fixed; z-index: -1; inset: -40px; pointer-events: none;
    background: url('/workspace-assets/assets/topography.svg') right -120px top -60px / 1400px 1000px no-repeat;
    opacity: .05; animation: pw-drift 90s ease-in-out infinite alternate;
  }
  @keyframes pw-twinkle { from { opacity: .26; } to { opacity: .42; } }
  @keyframes pw-drift { to { transform: translate3d(-36px, 22px, 0) rotate(.6deg); } }

  /* ---------- Brand ---------- */
  /* The same mark as the homepage: the image's own dark ground as a plain
     rounded tile, and a filter that turns its ribbon from teal to sage.
     No ring, shadow or glow. */
  body[data-workspace-view] .topbar .brand-woven-p {
    mix-blend-mode: normal; border-radius: 10px; filter: contrast(1.35) hue-rotate(-48deg) saturate(.5);
    box-shadow: none;
  }
  body[data-workspace-view] .topbar .brand-name { color: var(--pw-ink); }

  /* ---------- Navigation: four areas, four tones ---------- */
  body[data-workspace-view] .primary-nav { gap: 4px; }
  body[data-workspace-view] .primary-nav .nav-item { --tone: var(--pw-star); --tone-rgb: 195, 207, 232; }
  body[data-workspace-view] .primary-nav .nav-item[data-view="progress"] { --tone: var(--pw-sage); --tone-rgb: 160, 188, 132; }
  body[data-workspace-view] .primary-nav .nav-item[data-view="build"] { --tone: var(--pw-clay); --tone-rgb: 213, 141, 105; }
  body[data-workspace-view] .primary-nav .nav-item[data-view="schoolwork"] { --tone: var(--pw-river); --tone-rgb: 112, 186, 174; }
  body[data-workspace-view] .primary-nav .nav-item {
    position: relative; min-height: 46px; padding: 12px 18px 12px 16px; border: 1px solid transparent; background: transparent;
    color: var(--pw-muted); box-shadow: none; backdrop-filter: none; transition: background .3s var(--pw-ease), color .3s, border-color .3s;
  }
  body[data-workspace-view] .primary-nav .nav-item .path-nav-icon { color: var(--tone); opacity: .85; transition: opacity .3s, filter .3s; }
  body[data-workspace-view] .primary-nav .nav-item:hover { background: rgba(var(--tone-rgb), .08); border-color: transparent; color: var(--pw-ink); }
  body[data-workspace-view] .primary-nav .nav-item.active,
  body[data-workspace-view] .primary-nav .nav-item.active:hover {
    background: linear-gradient(90deg, rgba(var(--tone-rgb), .24), rgba(var(--tone-rgb), .07)); border-color: rgba(var(--tone-rgb), .38);
    color: var(--pw-ink); box-shadow: inset 0 1px 0 rgba(232, 238, 248, .05);
  }
  body[data-workspace-view] .primary-nav .nav-item.active .path-nav-icon { opacity: 1; }

  /* ---------- People: learner tags in oak ---------- */
  body[data-workspace-view] .learner-pill, body[data-workspace-view] .add-learner-pill, body[data-workspace-view] .workspace-account-toggle {
    background: rgba(14, 15, 18, .72); border-color: rgba(201, 160, 116, .28); color: var(--pw-muted); backdrop-filter: blur(12px);
    transition: background .25s, color .25s, border-color .25s;
  }
  body[data-workspace-view] .add-learner-pill { border-style: dashed; }
  body[data-workspace-view] .workspace-account-toggle { border-color: var(--pw-line); }
  body[data-workspace-view] .learner-pill:hover, body[data-workspace-view] .add-learner-pill:hover { background: rgba(201, 160, 116, .12); border-color: rgba(201, 160, 116, .55); color: var(--pw-ink); }
  body[data-workspace-view] .workspace-account-toggle:hover { background: var(--pw-soft); color: var(--pw-ink); }
  body[data-workspace-view] .learner-pill.selected { background: var(--pw-oak); border-color: var(--pw-oak); color: var(--pw-on-tone); box-shadow: none; }
  body[data-workspace-view] .learner-active-badge { background: var(--pw-oak); color: var(--pw-on-tone); }
  body[data-workspace-view] .workspace-account-panel { background: #16181c; border-color: var(--pw-line); box-shadow: 0 24px 60px rgba(0, 0, 0, .5); }
  body[data-workspace-view] .workspace-menu-item:hover, body[data-workspace-view] .workspace-menu-item[aria-current] { background: rgba(var(--page-rgb), .1); border-color: rgba(var(--page-rgb), .28); }

  /* The fade behind the learner tags: frosted rather than flat, so the
     moonlight and the grain carry through and scrolled content still hides. */
  body[data-workspace-view]:not([data-workspace-view="journey"]) .workspace-top-tools::before {
    background: linear-gradient(to bottom, rgba(14, 15, 18, .84) 0, rgba(14, 15, 18, .62) 70%, transparent);
    backdrop-filter: blur(16px);
  }

  /* ---------- Type and page headers ---------- */
  /* Small labels take the area's tone, like its tabs and marker. */
  body[data-workspace-view] #workspace :is(.eyebrow, .journey-hero-eyebrow, .next-step-eyebrow) { color: var(--page); letter-spacing: .12em; }
  /* Starter names were dark navy on a dark card (unreadable before this redesign too). */
  body[data-workspace-view] .concept-copy strong { color: var(--pw-ink); }
  body[data-workspace-view] .page-header { position: relative; }

  /* ---------- Controls ---------- */
  /* Tabs and toggles: the selected one is filled with the area's tone. */
  body[data-workspace-view] .page-tabs { border-color: var(--pw-line); background: rgba(14, 15, 18, .7); backdrop-filter: blur(10px); }
  body[data-workspace-view] .page-tab { transition: background .25s, color .25s; }
  body[data-workspace-view] .page-tab:hover { background: rgba(var(--page-rgb), .1); }
  body[data-workspace-view] .page-tab.active, body[data-workspace-view] .page-tab.active:hover { background: var(--page); color: var(--pw-on-tone); }
  /* Buttons: wheat acts; the rest are quiet until hovered, then the area's tone. */
  body[data-workspace-view] .button { border-color: var(--pw-line); background: rgba(232, 238, 248, .03); transition: background .25s, border-color .25s, color .25s, transform .3s var(--pw-ease), box-shadow .3s; }
  body[data-workspace-view] .button:hover { background: rgba(var(--page-rgb), .12); border-color: rgba(var(--page-rgb), .55); }
  body[data-workspace-view] .button:active { transform: scale(.98); }
  body[data-workspace-view] .button.primary { background: var(--pw-wheat); border-color: var(--pw-wheat); color: var(--pw-on-tone); box-shadow: 0 8px 18px -12px rgba(0, 0, 0, .8), inset 0 -1px 0 rgba(90, 64, 18, .22); }
  body[data-workspace-view] .button.primary:hover { background: var(--pw-button-hover); border-color: var(--pw-button-hover); transform: translateY(-1px); box-shadow: 0 12px 22px -12px rgba(0, 0, 0, .85), inset 0 -1px 0 rgba(90, 64, 18, .22); }
  body[data-workspace-view] .button.danger, body[data-workspace-view] .button.ghost.danger { border-color: rgba(241, 131, 132, .4); color: var(--pw-danger); }
  body[data-workspace-view] .button.danger:hover { background: rgba(241, 131, 132, .1); border-color: rgba(241, 131, 132, .7); }
  body[data-workspace-view] .button:disabled, body[data-workspace-view] .button[aria-disabled="true"], body[data-workspace-view] .button:disabled:hover { background: rgba(232, 238, 248, .025); border-color: var(--pw-line-soft); color: #70757b; box-shadow: none; transform: none; }
  body[data-workspace-view] .app-shell :is(input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=file]), textarea, select) { border-color: var(--pw-field); border-radius: 12px; background-color: rgba(9, 10, 12, .55); transition: border-color .2s, box-shadow .2s; }
  body[data-workspace-view] .app-shell :is(input, textarea, select):focus { border-color: var(--pw-wheat); box-shadow: 0 0 0 4px rgba(230, 196, 124, .14); }
  body[data-workspace-view] .app-shell :is(input, textarea)::placeholder { color: var(--pw-faint); }
  body[data-workspace-view] .app-shell :is(button, a, input, textarea, select, summary):focus-visible { outline-color: var(--pw-wheat); }
  /* The map takes the keyboard too; it had the browser's thin blue ring. */
  body[data-workspace-view="journey"] :is(.path-constellation-canvas, .path-tracker-canvas):focus-visible { outline: 2px solid var(--pw-wheat) !important; }
  body[data-workspace-view] input[type=checkbox], body[data-workspace-view] input[type=radio] { accent-color: var(--pw-sage); }
  body[data-workspace-view] .choice-chip { border-color: var(--pw-line); }
  body[data-workspace-view] .choice-chip:has(input:checked) { border-color: var(--page); background: rgba(var(--page-rgb), .16); }

  /* ---------- Surfaces: soft, lit from above, alive on hover ---------- */
  body[data-workspace-view] .app-shell :is(.privacy-card, .plan-card, .empty-state, .lesson-preview, .builder-form, .draft-editor, .photo-review-panel, .learner-create-panel, .schoolwork-request, .library-controls, .library-documents, .map-activity-topic, .learning-progress-section, .map-activity-controls, .account-view > section, .record-list, .journey-stat, .learner-card, .saved-card, .review-record-item, .topic-picker-card, .schoolwork-proposal, .parent-action-card, .library-document, .printable-card) {
    border-color: var(--pw-line-soft); border-radius: 20px; background: var(--pw-card);
    box-shadow: inset 0 1px 0 rgba(232, 238, 248, .045), 0 1px 0 rgba(0, 0, 0, .35);
  }
  body[data-workspace-view] .app-shell :is(.learner-card, .saved-card, .topic-picker-card, .printable-card, .library-document) {
    transition: transform .45s var(--pw-ease), border-color .3s, box-shadow .45s var(--pw-ease);
  }
  body[data-workspace-view] .app-shell :is(.learner-card, .saved-card, .topic-picker-card, .printable-card):hover {
    transform: translateY(-3px); border-color: rgba(var(--page-rgb), .5);
    box-shadow: inset 0 1px 0 rgba(232, 238, 248, .06), 0 22px 44px -24px rgba(0, 0, 0, .85);
  }

  /* Each subject strand keeps one earth hue, here and on both maps. */
  body[data-workspace-view] [data-subject="Computing"], body[data-workspace-view] [data-area="Computing"] { --subject: var(--pw-dusk); --subject-rgb: 127, 172, 203; }
  body[data-workspace-view] [data-subject="English"], body[data-workspace-view] [data-area="Reading & writing"] { --subject: var(--pw-clay); --subject-rgb: 213, 141, 105; }
  body[data-workspace-view] [data-subject="History"], body[data-workspace-view] [data-area="Social studies"] { --subject: var(--pw-heather); --subject-rgb: 194, 147, 181; }
  body[data-workspace-view] [data-subject="Learning to Learn"] { --subject: var(--pw-lichen); --subject-rgb: 164, 157, 88; }
  body[data-workspace-view] [data-subject="Life Skills"] { --subject: var(--pw-sage); --subject-rgb: 160, 188, 132; }
  body[data-workspace-view] [data-subject="Mathematics"], body[data-workspace-view] [data-area="Math"] { --subject: var(--pw-wheat); --subject-rgb: 230, 196, 124; }
  body[data-workspace-view] [data-subject="Personal & Social Development"], body[data-workspace-view] [data-area="Art"] { --subject: var(--pw-rose); --subject-rgb: 214, 165, 156; }
  body[data-workspace-view] [data-subject="Science"], body[data-workspace-view] [data-area="Science"] { --subject: var(--pw-river); --subject-rgb: 112, 186, 174; }
  /* A card for a topic wears its strand: a band along the top, a tinted
     corner, and its label in the strand's hue. */
  body[data-workspace-view] .app-shell :is(.topic-picker-card, .map-activity-topic, .printable-card):is([data-subject], [data-area]) {
    background:
      linear-gradient(var(--subject, var(--page)), var(--subject, var(--page))) top / 100% 3px no-repeat,
      radial-gradient(130% 90% at 0% 0%, rgba(var(--subject-rgb, var(--page-rgb)), .06), transparent 58%),
      var(--pw-card);
  }
  body[data-workspace-view] .app-shell .next-topic-card { border-color: rgba(var(--subject-rgb, var(--page-rgb)), .34); }
  body[data-workspace-view] .app-shell :is(.topic-picker-card, .printable-card):is([data-subject], [data-area]):hover { border-color: rgba(var(--subject-rgb, var(--page-rgb)), .6); }
  body[data-workspace-view] :is(.topic-card-subject, .printable-card-meta) { color: var(--subject, var(--page)); }
  body[data-workspace-view] .topic-age-chip { border-color: var(--pw-line); }
  body[data-workspace-view] .app-shell .saved-card { background: linear-gradient(var(--pw-clay), var(--pw-clay)) left / 3px 100% no-repeat, var(--pw-card); }
  body[data-workspace-view] .app-shell .learner-card { background: linear-gradient(var(--pw-oak), var(--pw-oak)) left / 3px 100% no-repeat, var(--pw-card); }

  body[data-workspace-view] :is(.backups-disclosure, .parent-map-details, .full-editor-disclosure, .review-record-details, .consent-row, .privacy-callout) { border-color: var(--pw-line-soft); background: rgba(9, 10, 12, .4); }
  body[data-workspace-view] .privacy-callout { border-left-color: var(--pw-sage); }
  body[data-workspace-view] .upload-drop { border-color: rgba(var(--page-rgb), .4); background: rgba(var(--page-rgb), .04); }
  body[data-workspace-view] .upload-drop:hover, body[data-workspace-view] .upload-drop:focus-within { border-color: var(--page); background: rgba(var(--page-rgb), .09); }
  body[data-workspace-view] .workspace-status:not(:empty) { border-color: rgba(160, 188, 132, .5); background: rgb(22, 26, 28); box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .8); }
  body[data-workspace-view] .workspace-status.error:not(:empty) { border-color: rgba(241, 131, 132, .6); }

  /* ---------- Growth marks: seed (clay), sprout (sage), harvest (wheat) ---------- */
  .status-mark.status-comfortable { background: var(--pw-wheat); box-shadow: 0 0 10px rgba(230, 196, 124, .55); }
  .status-mark.status-practicing { border-color: var(--pw-sage); background: linear-gradient(90deg, var(--pw-sage) 50%, transparent 50%); }
  .status-mark.status-introduced { border-color: var(--pw-clay); background: radial-gradient(circle, var(--pw-clay) 0 2px, transparent 2.6px); }
  body[data-workspace-view] .record-stat { border-color: var(--pw-line); background: rgba(14, 15, 18, .6); }
  body[data-workspace-view] .record-stat:has(.status-comfortable) { border-color: rgba(230, 196, 124, .45); background: rgba(230, 196, 124, .1); }
  body[data-workspace-view] .record-stat:has(.status-practicing) { border-color: rgba(160, 188, 132, .45); background: rgba(160, 188, 132, .1); }
  body[data-workspace-view] .record-stat:has(.status-introduced) { border-color: rgba(213, 141, 105, .45); background: rgba(213, 141, 105, .1); }
  body[data-workspace-view] .record-list .record-row.parent-note-card { transition: background .3s; }
  body[data-workspace-view] .record-list .record-row.parent-note-card:hover { background: rgba(232, 238, 248, .025); }

  /* ---------- The Path ---------- */
  body[data-workspace-view] .next-step-card {
    border-color: rgba(222, 228, 238, .16) !important; border-radius: 24px !important;
    background: radial-gradient(120% 90% at 0% 0%, rgba(var(--page-rgb), .06), transparent 55%), rgba(20, 22, 26, .88) !important;
    box-shadow: 0 30px 70px -30px rgba(0, 0, 0, .9), inset 0 1px 0 rgba(232, 238, 248, .06) !important;
    backdrop-filter: blur(18px) saturate(1.08);
  }
  /* In the tracker the card stops above the caption that sits under it. */
  body[data-workspace-view="journey"] .journey-view:has(.path-explorer[data-view="tracker"]) .next-step-card:not(.is-running) { max-height: calc(100dvh - 252px - 212px); }
  /* The map's fine print: nothing under 11px. */
  body[data-workspace-view="journey"] :is(.path-status-legend, .path-legend-item, .path-tracker-key, .path-gesture-hint, .path-topic-count, .path-age-note) { font-size: .75rem; }
  body[data-workspace-view="journey"] :is(.path-browser-panel, .path-selected-detail) { border-color: var(--pw-line); background: rgba(18, 20, 24, .92); backdrop-filter: blur(20px); }
  body[data-workspace-view="journey"] .path-camera-controls :is(button, .button) { border-color: var(--pw-line); background: rgba(14, 15, 18, .8); backdrop-filter: blur(10px); }

  /* ---------- Between the constellation and the tracker ---------- */
  /* The age strip arrives with the tracker's grid, while the stars are still
     landing; captions and controls follow one after another once they have. */
  body[data-workspace-view] .path-explorer.is-flying.is-arriving .path-age-markers { opacity: 1; transition: opacity .45s ease; }
  body[data-workspace-view] .path-explorer:not(.is-flying) :is(.path-subject-labels, .path-age-markers, .path-tracker-intro, .path-tracker-key, .path-camera-controls, .path-gesture-hint) { transition: opacity .5s ease; }
  body[data-workspace-view] .path-explorer:not(.is-flying) .path-tracker-intro { transition-delay: .08s; }
  body[data-workspace-view] .path-explorer:not(.is-flying) .path-tracker-key { transition-delay: .16s; }
  body[data-workspace-view] .path-explorer:not(.is-flying) :is(.path-camera-controls, .path-gesture-hint) { transition-delay: .22s; }

  /* Entering a page: no rise-in. Content is simply there, so nothing reads
     as faded or half-loaded while a parent starts to read (UI review, Run E). */

  /* Until the script has placed the page (it sets data-workspace-view on the
     body, usually within a few tenths of a second), the empty frame waits
     unseen, so the header and page don't appear in one place and jump to
     another. If the script never arrives, the frame shows after 1.5s. */
  body:not([data-workspace-view]) #lesson-workspace-app { animation: pw-frame-wait 1.5s; }
  @keyframes pw-frame-wait { from, to { visibility: hidden; } }
}

/* ---------- Mr. Buttons docked: the page makes room beside him ---------- */
@media screen and (min-width: 1360px) {
  body[data-workspace-view] .main-content, body[data-workspace-view] .workspace-top-tools,
  body[data-workspace-view="journey"] :is(.path-camera-controls, .path-browser-panel, .path-selected-detail, .path-map-footer, .vault-sync-status) {
    transition: margin-right .5s var(--pw-ease), right .5s var(--pw-ease);
  }
  body[data-assistant="open"][data-workspace-view]:not([data-workspace-view="journey"]) .main-content { width: auto !important; margin-right: 446px !important; }
  body[data-assistant="open"][data-workspace-view] .workspace-top-tools { right: 446px; }
  body[data-assistant="open"][data-workspace-view="journey"] .path-camera-controls { right: 446px; }
  body[data-assistant="open"][data-workspace-view="journey"] :is(.path-browser-panel, .path-selected-detail) { right: 446px; }
  body[data-assistant="open"][data-workspace-view="journey"] .path-map-footer { right: 840px; }
  body[data-assistant="open"][data-workspace-view="journey"] .vault-sync-status { right: 450px; }
}

/* ---------- Phones and touch ---------- */
@media screen and (max-width: 760px) {
  /* The Path's status line sits over the brand row, clear of the title, the view switch and the map. */
  body[data-workspace-view="journey"] :is(.workspace-status, .catalog-status:not(.success)):not(:empty) {
    top: max(8px, env(safe-area-inset-top, 0px)); left: 14px; right: 14px; width: auto; max-width: none; transform: none; text-align: center;
  }
  body[data-workspace-view] .primary-nav .nav-item { font-size: .75rem; }
}
/* Fingers need 44px. */
@media screen and (pointer: coarse), screen and (max-width: 760px) {
  body[data-workspace-view] :is(.learner-pill, .add-learner-pill, .workspace-account-toggle, .page-tab) { min-height: 44px; }
  body[data-workspace-view] .workspace-account-toggle { min-width: 44px; }
  body[data-workspace-view="journey"] .path-view-switch { padding: 1px; }
  body[data-workspace-view="journey"] .path-view-button { min-height: 44px; }
  body[data-workspace-view="journey"] :is(.path-icon-button, .path-search-toggle) { min-width: 44px; min-height: 44px; }
  /* Disclosures ("Adjust activity") were a single line of text to hit. */
  body[data-workspace-view] #workspace summary { min-height: 44px; align-content: center; }
}

@media screen and (prefers-reduced-motion: reduce) {
  body[data-workspace-view]::before, body[data-workspace-view] #lesson-workspace-app::before { animation: none !important; }
  body[data-workspace-view] .app-shell * { transition-duration: 0s !important; }
}
