/* Screenery viewer: a dark workbench so the template is the brightest thing on screen.
   Layout: toolbar / stage (iframe) + optional side panel / pager. */
:root {
  --bg: #101214;
  --bg-2: #1a1d21;
  --bg-3: #262a30;
  --text: #eef0f2;
  --text-2: #a9b0b9;
  --line: rgb(238 240 242 / 0.14);
  --accent: #3d6bff;
  --pass: #8fd6a4;
  --fail: #8aa6ff;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --sans: 'Epilogue', ui-sans-serif, system-ui, sans-serif;
  --mono: 'Spline Sans Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --panel-w: min(30rem, 100vw);
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; display: grid; grid-template-rows: auto 1fr auto; grid-template-columns: 1fr auto;
  background: var(--bg); color: var(--text);
  font: 400 0.9375rem/1.5 var(--sans); -webkit-font-smoothing: antialiased;
  accent-color: var(--accent); scrollbar-color: var(--bg-3) var(--bg);
  overflow: hidden;
}
::selection { background: var(--accent); color: #101214; }
h1, p, dl, dd, ul, pre { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
@view-transition { navigation: auto; }

/* Toolbar */
.bar { grid-column: 1 / -1; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 1rem; padding: 0.6rem 1rem; border-bottom: 1px solid var(--line); }
.bar__back { display: inline-flex; align-items: center; gap: 0.4rem; min-height: 2.75rem; padding: 0 0.6rem 0 0.3rem; text-decoration: none; color: var(--text-2); border-radius: 8px; justify-self: start; transition: color 0.2s, background 0.2s; }
.bar__back:hover { color: var(--text); background: var(--bg-2); }
.bar__title { display: flex; align-items: baseline; gap: 0.75rem; min-width: 0; }
.bar__title h1 { font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar__type { flex: 1 1 0; min-width: 0; font: 400 0.8125rem/1.4 var(--mono); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar__tools { display: flex; align-items: center; gap: 0.5rem; justify-self: end; }

.seg { display: inline-flex; padding: 3px; background: var(--bg-2); border-radius: 10px; }
.seg button { display: grid; place-items: center; width: 2.6rem; height: 2.35rem; background: none; border: 0; border-radius: 7px; color: var(--text-2); cursor: pointer; transition: background 0.2s, color 0.2s; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed='true'] { background: var(--bg-3); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / 0.4); }

.tool { display: inline-flex; align-items: center; min-height: 2.75rem; padding: 0 0.95rem; background: none; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background 0.2s, border-color 0.2s; }
.tool:hover { background: var(--bg-2); border-color: rgb(238 240 242 / 0.3); }
.tool[aria-expanded='true'] { background: var(--bg-3); }
.tool--solid { background: var(--text); color: var(--bg); border-color: var(--text); }
.tool--solid:hover { background: #fff; border-color: #fff; }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Stage */
.stage {
  min-width: 0; min-height: 0; display: grid; place-items: stretch; padding: 0;
  background-color: var(--bg);
  background-image: radial-gradient(rgb(238 240 242 / 0.09) 1px, transparent 1px);
  background-size: 18px 18px;
  overflow: auto;
}
.stage__frame { width: 100%; height: 100%; margin: 0 auto; background: #fff; transition: width 0.55s var(--ease), height 0.55s var(--ease), border-radius 0.55s var(--ease); view-transition-name: stage; }
.stage iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.stage[data-size='tablet'], .stage[data-size='phone'] { padding: 1.5rem; place-items: start center; }
.stage[data-size='tablet'] .stage__frame { width: 820px; max-width: 100%; height: 100%; min-height: 34rem; border-radius: 14px; overflow: hidden; box-shadow: 0 0 0 1px var(--line), 0 30px 60px -20px #000; }
.stage[data-size='phone'] .stage__frame { width: 390px; max-width: 100%; height: min(844px, 100%); min-height: 30rem; border-radius: 28px; overflow: hidden; box-shadow: 0 0 0 1px var(--line), 0 0 0 8px var(--bg-2), 0 0 0 9px var(--line), 0 30px 60px -20px #000; }
.stage__missing { place-self: center; padding: 2rem; color: var(--text-2); }

/* Side panel */
.panel { grid-row: 2; grid-column: 2; width: var(--panel-w); min-height: 0; display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--bg); }
.panel[hidden] { display: none; }
.panel:focus { outline: none; }
.panel__head { display: flex; align-items: center; justify-content: space-between; padding: 0.6rem 0.75rem 0 1.25rem; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 1.5rem; }
.tabs button { padding: 0.7rem 0 0.8rem; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--text-2); font-weight: 500; cursor: pointer; }
.tabs button[aria-selected='true'] { color: var(--text); border-bottom-color: var(--accent); }
.panel__close { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; background: none; border: 0; border-radius: 8px; color: var(--text-2); cursor: pointer; }
.panel__close:hover { background: var(--bg-2); color: var(--text); }
.pane { flex: 1; min-height: 0; overflow: auto; padding: 1.5rem 1.25rem 2rem; }
.pane[hidden] { display: none; }
.pane__world { font-size: 1.25rem; line-height: 1.4; letter-spacing: -0.015em; text-wrap: pretty; }
.spec { margin-top: 1.75rem; }
.spec > div { display: grid; grid-template-columns: 6.5rem 1fr; gap: 1rem; padding: 0.9rem 0; border-top: 1px solid var(--line); }
.spec dt { color: var(--text-2); font: 400 0.8125rem/1.6 var(--mono); }
.spec code, .tech li { font-family: var(--mono); font-size: 0.8125rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem 0.9rem; }
.chip { display: inline-flex; align-items: center; gap: 0.4rem; font: 400 0.8125rem/1.6 var(--mono); }
.chip i { width: 0.95rem; height: 0.95rem; border-radius: 50%; box-shadow: 0 0 0 1px var(--line); }
.tech { display: grid; gap: 0.3rem; }
.tech li { font-family: var(--sans); font-size: 0.9375rem; }
.pane__more { margin-top: 1.25rem; padding-top: 1.1rem; border-top: 1px solid var(--line); }
.pane__more a { display: inline-flex; align-items: center; min-height: 2.75rem; font-weight: 500; text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 0.3em; }
.pane__more a:hover { color: #fff; text-decoration-color: currentColor; }

/* Checks pane: the measured report for this template */
.pane__note { margin-top: 0.6rem; color: var(--text-2); font-size: 0.875rem; text-wrap: pretty; }
.pane__h { margin: 2rem 0 0.6rem; font-size: 0.9375rem; font-weight: 600; letter-spacing: -0.005em; }
.runs { border-bottom: 1px solid var(--line); }
.run { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0.25rem 1rem; padding: 0.7rem 0; border-top: 1px solid var(--line); }
.run__name { font: 400 0.8125rem/1.6 var(--mono); font-variant-numeric: tabular-nums; }
.run__status { display: inline-flex; align-items: center; gap: 0.45rem; font-weight: 600; font-size: 0.875rem; color: var(--pass); }
.run__status::before { content: ''; width: 16px; height: 16px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m3 8.5 3.2 3.2L13 4.8' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m3 8.5 3.2 3.2L13 4.8' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; }
.run--fail .run__status { color: var(--fail); }
.run--fail .run__status::before { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 4 8 8M12 4l-8 8' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 4 8 8M12 4l-8 8' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E"); }
.run__issues { grid-column: 1 / -1; display: grid; gap: 0.5rem; padding: 0.2rem 0 0.3rem; font-size: 0.875rem; }
.run__issues li { display: grid; gap: 0.1rem; }
.run__issues b { font-weight: 500; }
.run__issues span { color: var(--text-2); font: 400 0.78rem/1.55 var(--mono); overflow-wrap: anywhere; }
.spec--tight { margin-top: 0; border-bottom: 1px solid var(--line); }
.spec--tight > div { padding: 0.7rem 0; }
.spec--tight dd { font-variant-numeric: tabular-nums; }
.checks { display: grid; border-bottom: 1px solid var(--line); }
.checks li { padding: 0.55rem 0; border-top: 1px solid var(--line); font-size: 0.875rem; text-wrap: pretty; }
.checks .checks__skipped { color: var(--fail); }
.pane:focus-visible { outline-offset: -2px; }

/* Secondary actions live in the toolbar when there is room, in the panel when there is not */
.panel__actions { display: none; flex-wrap: wrap; gap: 0.5rem; padding: 0.75rem 1.25rem; border-top: 1px solid var(--line); }
.panel__actions .tool { flex: 1 1 auto; justify-content: center; }

#pane-code { display: flex; flex-direction: column; padding: 0; }
#pane-code[hidden] { display: none; }
.files { display: flex; align-items: center; gap: 0.25rem; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); }
.files button { min-height: 2.25rem; padding: 0 0.7rem; background: none; border: 0; border-radius: 7px; color: var(--text-2); font: 400 0.8125rem/1 var(--mono); cursor: pointer; }
.files button:hover { color: var(--text); background: var(--bg-2); }
.files button[aria-pressed='true'] { color: var(--text); background: var(--bg-3); }
.files .files__copy { margin-left: auto; border: 1px solid var(--line); color: var(--text); font-family: var(--sans); font-weight: 500; }
.code { flex: 1; min-height: 0; overflow: auto; padding: 1rem 1.25rem 2rem; font: 400 0.78rem/1.65 var(--mono); color: #d3d8de; tab-size: 2; white-space: pre; }

/* Pager */
.pager { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; padding: 0 1rem; border-top: 1px solid var(--line); font-size: 0.875rem; }
.pager a { display: inline-flex; align-items: center; gap: 0.5rem; min-height: 2.75rem; text-decoration: none; color: var(--text-2); transition: color 0.2s; }
.pager a:hover { color: var(--text); }
.pager a:last-child { justify-self: end; }
.pager__count { font: 400 0.8125rem/1 var(--mono); color: var(--text-2); }

@media (max-width: 82rem) {
  .tool--wide { display: none; }
  .panel__actions { display: flex; }
}
@media (max-width: 60rem) {
  .bar__back span { display: none; }
  .bar__type { display: none; }
  #toggle-panel { font-size: 0; padding: 0; width: 2.75rem; justify-content: center; }
  #toggle-panel::before { content: ''; width: 18px; height: 18px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='m7 6-4 4 4 4M13 6l4 4-4 4' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='m7 6-4 4 4 4M13 6l4 4-4 4' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; }
  .panel { position: fixed; inset: 0; z-index: 30; width: auto; border-left: 0; }
}
@media (max-width: 40rem) {
  .seg { display: none; }
  .tool--solid { font-size: 0; padding: 0; width: 2.75rem; justify-content: center; }
  .tool--solid::before { content: ''; width: 18px; height: 18px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M8 4H4v12h12v-4M11 4h5v5M16 4l-7 7' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M8 4H4v12h12v-4M11 4h5v5M16 4l-7 7' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; }
  .stage[data-size] { padding: 0; }
  .stage[data-size] .stage__frame { width: 100%; height: 100%; border-radius: 0; box-shadow: none; }
  .pager #prev-name, .pager #next-name { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) { * { transition-duration: 0.01ms !important; } }
