/* /editor page chrome. The editor's own stylesheet (yarramate's styles.css)
   is loaded before this one; it paints the editor and sets the shared tokens,
   which this file restates as the site's literal values (BRIEF section 3).

   The route is the editor: one slim question bar above it, the editor filling
   the rest of the viewport, a one-line foot, and a collapsed hand-off drawer.
   Everything that is not the map stays out of its way. */
:root {
  --paper: #e8eef0;
  --ink: #182228;
  --cobalt: #2457a6;
  --eucalyptus: #416f65;
  --ochre: #8c4d18;
  --failure: #a3403a;
  --quiet: #5c676c;
  --rule: #c3ccd0;
  --rule-firm: #9aa5aa;
  --sheet: #f5f8f9;
  --display: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --body: 'Avenir Next', Avenir, -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --utility: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}
html, body { height: 100%; margin: 0; }
body.editor-page {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 var(--body);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100dvh;
  overflow: hidden;
}
.editor-page a { color: var(--cobalt); }
.editor-page :focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 30; padding: 8px 12px; background: var(--sheet); color: var(--ink); border: 1px solid var(--rule-firm); }
.skip:focus { top: 8px; }

/* Nav: the shared markup, compact on this route */
.site-nav { display: flex; align-items: center; gap: 20px; padding: 9px 24px; border-bottom: 1px solid var(--rule); background: var(--paper); }
.site-nav .brand { font-family: var(--display); font-size: 21px; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; }
.site-nav .brand span { color: var(--eucalyptus); }
.site-nav nav { margin-left: auto; display: flex; align-items: center; gap: 18px; font-size: 14px; }
.site-nav nav a { color: var(--quiet); font-weight: 600; text-decoration: none; }
.site-nav nav a:hover { color: var(--ink); }
.site-nav nav a.btn { background: var(--eucalyptus); color: var(--paper); padding: 7px 13px; }

/* The route: the editor, then one line beneath it (drawer, text editor, reset) */
main.editor-main {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
}
/* With the hand-off drawer open the route scrolls; the map keeps a working height. */
main.editor-main:has(.handoff[open]) { overflow-y: auto; grid-template-rows: minmax(60dvh, 1fr) auto; }

.eyebrow { font-family: var(--utility); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--eucalyptus); }

/* The line beneath the editor: the hand-off drawer's summary on the left,
   the text editor pop-over and Start again on the right. Opening the drawer
   moves it below the actions and lets it take the full width. */
.foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; padding: 6px 24px; border-top: 1px solid var(--rule-firm); background: var(--paper); }
.foot-actions { order: 2; margin-left: auto; display: flex; gap: 18px; align-items: center; flex-shrink: 0; position: relative; }
details.popover > summary { cursor: pointer; color: var(--cobalt); font-weight: 600; font-size: 14px; list-style: none; white-space: nowrap; }
details.popover > summary::-webkit-details-marker { display: none; }
details.popover > summary::after { content: ' \203A'; }
.popover-body { position: absolute; right: 0; top: calc(100% + 10px); width: min(680px, calc(100vw - 48px)); background: #ffffff; border: 1px solid var(--rule-firm); box-shadow: 0 14px 40px rgba(24, 34, 40, 0.16); padding: 14px 18px; z-index: 20; font-size: 14px; }
details.popover.up .popover-body { top: auto; bottom: calc(100% + 10px); }
.popover-body p { margin: 0 0 8px; }
.popover-body p:last-child { margin-bottom: 0; }
.popover-body .why { color: var(--quiet); }
.popover-body .how b { font-weight: 600; }
.popover-body .counts { font-family: var(--utility); font-size: 12px; color: var(--quiet); }
.popover-body .counts b { color: var(--ochre); font-weight: 600; }
.drawer-file { display: flex; gap: 10px; align-items: center; margin: 0 0 8px; font-family: var(--utility); font-size: 12px; color: var(--quiet); }
.drawer-file select { font: inherit; border: 1px solid var(--rule-firm); background: var(--paper); color: var(--ink); padding: 2px 4px; }
.drawer-file select[hidden] { display: none; }
.popover-body textarea { width: 100%; height: min(320px, 50dvh); font-family: var(--utility); font-size: 12px; line-height: 1.5; border: 1px solid var(--rule-firm); background: var(--sheet); color: var(--ink); padding: 8px; resize: vertical; white-space: pre; tab-size: 2; box-sizing: border-box; }
.status { min-height: 1.2em; margin-top: 6px; font-family: var(--utility); font-size: 12px; color: var(--quiet); white-space: pre-wrap; }
.status.good { color: var(--eucalyptus); }
.status.bad { color: var(--failure); }

/* The editor's frame: everything the viewport has left */
.frame { position: relative; min-height: 0; background: var(--sheet); }
.frame .mount { position: absolute; inset: 0; }
.frame .mount > .visual-shell { height: 100%; }
.frame-loading { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; font-family: var(--utility); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--quiet); pointer-events: none; }
.frame.mounted .frame-loading { display: none; }
.frame-loading.failed { color: var(--failure); text-transform: none; letter-spacing: 0; pointer-events: auto; }

button.link { font: inherit; background: none; border: 0; padding: 0; color: var(--quiet); font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
button.link:hover { color: var(--ink); text-decoration: underline; }

/* The hand-off drawer: documents, the folder, the recipes */
.handoff { order: 1; flex: 1 1 auto; min-width: 0; }
.handoff[open] { order: 3; flex-basis: 100%; margin: 4px -24px -6px; border-top: 1px solid var(--rule); }
.handoff > summary { cursor: pointer; padding: 2px 0; font-size: 14px; font-weight: 600; color: var(--cobalt); list-style: none; }
.handoff[open] > summary { padding: 8px 24px; border-bottom: 1px solid var(--rule); }
.handoff > summary::-webkit-details-marker { display: none; }
.handoff > summary::after { content: ' \203A'; }
.agent-body { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 24px; padding: 20px 24px 28px; align-items: start; }
.card { border: 1px solid var(--rule-firm); background: var(--sheet); padding: 16px 20px 18px; }
.card h2 { font-family: var(--display); font-weight: 400; font-size: 24px; line-height: 1.15; margin: 4px 0 10px; }
.card p { margin: 0 0 10px; }
.card p.small { font-size: 13.5px; color: var(--quiet); }
.doc-tabs { display: flex; border: 1px solid var(--rule-firm); width: max-content; max-width: 100%; margin-bottom: 10px; }
.doc-tabs button { font: inherit; font-family: var(--utility); font-size: 12px; letter-spacing: 0.04em; background: var(--sheet); color: var(--ink); border: 0; border-right: 1px solid var(--rule-firm); padding: 6px 12px; cursor: pointer; }
.doc-tabs button:last-child { border-right: 0; }
.doc-tabs button[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.doc { max-height: 56dvh; overflow: auto; border: 1px solid var(--rule); background: #ffffff; padding: 14px 18px; font-size: 14px; }
.doc h3 { font-family: var(--display); font-weight: 400; font-size: 20px; margin: 0 0 8px; }
.doc h4 { font-weight: 600; font-size: 14.5px; margin: 14px 0 6px; }
.doc h5 { font-weight: 600; font-size: 13.5px; margin: 10px 0 4px; }
.doc p { margin: 0 0 8px; }
.doc ul { margin: 0 0 8px; padding-left: 20px; }
.doc code { font-family: var(--utility); font-size: 12px; background: var(--paper); padding: 0 3px; }
.doc table { border-collapse: collapse; width: 100%; font-size: 13px; }
.doc th, .doc td { text-align: left; vertical-align: top; padding: 5px 10px 5px 0; border-bottom: 1px solid var(--rule); }
.doc th { font-family: var(--utility); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--quiet); font-weight: 500; }
.folder { margin: 0 0 8px; font-family: var(--utility); font-size: 12px; line-height: 1.65; white-space: pre; overflow-x: auto; }
.folder b { font-weight: 600; }
.generated { margin: 12px 0 0; padding: 0; list-style: none; font-size: 13.5px; }
.generated li { padding: 5px 0; border-top: 1px solid var(--rule); }
.generated li span { color: var(--quiet); }
.download-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 6px 0 14px; }
.btn-primary { font: inherit; font-weight: 600; background: var(--eucalyptus); color: var(--paper); border: 0; padding: 9px 16px; cursor: pointer; }
.btn-primary[disabled] { background: var(--rule-firm); cursor: default; }
.download-note { font-family: var(--utility); font-size: 11.5px; color: var(--quiet); }
.platforms { border-left: 3px solid var(--eucalyptus); padding: 2px 0 2px 14px; margin: 0 0 14px; font-size: 14.5px; }
.platforms p { margin: 0 0 6px; }
.platforms .no { color: var(--ochre); }
.recipes { display: grid; gap: 8px; }
.recipe { border: 1px solid var(--rule); background: #ffffff; padding: 8px 10px; display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.recipe .name { font-weight: 600; font-size: 14px; }
.recipe .name small { display: block; font-weight: 400; color: var(--quiet); font-size: 12px; }
.recipe code { font-family: var(--utility); font-size: 12px; line-height: 1.5; background: var(--paper); padding: 5px 8px; display: block; overflow-x: auto; white-space: pre; }
.recipe .alt { grid-column: 2; font-size: 12.5px; color: var(--quiet); margin: 0; }
.recipe .alt code { display: inline; padding: 0 3px; white-space: normal; }
.recipe button { font: inherit; font-family: var(--utility); font-size: 12px; background: transparent; border: 1px solid var(--rule-firm); color: var(--ink); padding: 4px 8px; cursor: pointer; }
.path-note { margin: 12px 0 0; font-size: 13.5px; color: var(--quiet); }
.path-note code { font-family: var(--utility); font-size: 12px; }
.drift { border: 1px dashed var(--ochre); padding: 12px 16px; margin: 0 24px 24px; max-width: 80ch; }
.drift .eyebrow { color: var(--ochre); }
.drift p { margin: 4px 0 0; font-size: 14px; }

/* Footer */
.honesty { padding: 5px 24px; border-top: 1px solid var(--rule); font-family: var(--utility); font-size: 11px; line-height: 1.45; color: var(--quiet); }
.honesty p { margin: 0; }

@media (max-width: 1023px) {
  .agent-body { grid-template-columns: 1fr; }
  .recipe { grid-template-columns: 1fr; }
  .recipe .alt { grid-column: 1; }
  .site-nav { padding-inline: 16px; }
  .site-nav nav { gap: 12px; font-size: 13px; }
  .foot, .agent-body, .honesty { padding-inline: 16px; }
  .handoff[open] { margin-inline: -16px; }
  .handoff[open] > summary { padding-inline: 16px; }
  .drift { margin-inline: 16px; }
}
@media (max-width: 720px) {
  body.editor-page { height: auto; min-height: 100dvh; overflow: auto; }
  main.editor-main { height: auto; overflow: visible; grid-template-rows: auto auto; }
  .frame { height: 78dvh; }
  .foot-actions { margin-left: 0; width: 100%; position: static; flex-wrap: wrap; }
  .popover-body, details.popover.up .popover-body { position: static; width: auto; margin-top: 8px; box-shadow: none; }
  /* Phones: the links on one scrollable row, every one reachable. */
  .site-nav { flex-wrap: wrap; row-gap: 6px; }
  .site-nav nav { margin-left: 0; width: 100%; flex-wrap: nowrap; overflow-x: auto; gap: 14px; scrollbar-width: none; }
  .site-nav nav::-webkit-scrollbar { display: none; }
  .site-nav nav a { white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) {
  .editor-page * { scroll-behavior: auto !important; transition: none !important; }
}
