/* Viewer chrome: index, design page, catalog, login.
 *
 * Carried over from the thisislorenz/nell studio deck. nell's palette inverted:
 * the warm off-white of nell's selected chip is the paper and the cool charcoal
 * of nell's ground is the ink. There is no chromatic accent; emphasis is ink
 * weight. These values are chrome, not product, so they are the one place
 * outside system/tokens.css where colour literals are allowed.
 */

:root {
  color-scheme: light;
  --dl-paper:         #ece7e3;
  --dl-paper-sunk:    #e1dbd6;
  --dl-ink:           #121318;
  --dl-ink-secondary: #565760;
  --dl-ink-tertiary:  #918d88;
  --dl-rule:          #d5cec8;

  --dl-font: "Lab Grotesque", -apple-system, system-ui, sans-serif;
  --dl-t-display: 600 clamp(34px, 3.6vw, 56px)/1.06 var(--dl-font);
  --dl-t-h2:      600 clamp(24px, 2.4vw, 34px)/1.12 var(--dl-font);
  --dl-t-lede:    400 clamp(17px, 1.4vw, 20px)/1.5 var(--dl-font);
  --dl-t-body:    400 16px/1.5 var(--dl-font);
  --dl-t-caption: 400 13px/1.45 var(--dl-font);
  --dl-t-micro:   500 12px/1 var(--dl-font);

  --dl-pad: clamp(24px, 4.5vw, 84px);
  --dl-gap: clamp(24px, 3.6vw, 64px);
  --dl-logo-h: 34px;
}

:root.dark {
  color-scheme: dark;
  --dl-paper:         #121318;
  --dl-paper-sunk:    #1e1f24;
  --dl-ink:           #ece7e3;
  --dl-ink-secondary: #b8b8ba;
  --dl-ink-tertiary:  #9b99a0;
  --dl-rule:          #383940;
}

*, *::before, *::after { box-sizing: border-box; }

html { background: var(--dl-paper); }
body {
  margin: 0;
  min-height: 100svh;
  background: var(--dl-paper);
  color: var(--dl-ink);
  font: var(--dl-t-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--dl-ink); outline-offset: 2px; }

/* ---------- logo ----------
 * Fixed top left, as in the studio, and always a link back to the index. */
.dl-logo {
  position: fixed;
  top: var(--dl-pad);
  left: var(--dl-pad);
  z-index: 30;
  display: flex;
  color: var(--dl-ink);
  transition: opacity .15s ease-out;
}
.dl-logo:hover { opacity: .55; }
/* On the index, viewer/logo.js sets --dl-logo-out from 0 to 1 as the page
   scrolls: the logo blurs, lifts and fades out. */
.dl-logo[style*="--dl-logo-out"] {
  opacity: calc(1 - var(--dl-logo-out));
  filter: blur(calc(var(--dl-logo-out) * 10px));
  transform: translateY(calc(var(--dl-logo-out) * -8px));
  transition: none;
}
.dl-logo[style*="--dl-logo-out"]:hover { opacity: calc(.55 * (1 - var(--dl-logo-out))); }
.dl-logo[data-out] { visibility: hidden; pointer-events: none; }
.dl-logo svg { height: var(--dl-logo-h); width: auto; display: block; overflow: visible; }

.dl-meta { font: var(--dl-t-caption); color: var(--dl-ink-tertiary); font-variant-numeric: tabular-nums; }
.dl-lede { font: var(--dl-t-lede); color: var(--dl-ink-secondary); margin: 0; }

.dl-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--dl-rule);
  border-radius: 999px;
  background: transparent;
  font: 500 14px/1 var(--dl-font);
  color: var(--dl-ink);
  cursor: pointer;
  text-decoration: none;
  transition: background-color .12s ease-out, border-color .12s ease-out;
}
.dl-button:hover { background: var(--dl-paper-sunk); }
.dl-button[aria-pressed="true"] { background: var(--dl-ink); border-color: var(--dl-ink); color: var(--dl-paper); }
.dl-button svg { width: 16px; height: 16px; }
.dl-appearance { display: flex; flex: none; align-items: center; gap: 6px; }
@media (max-width: 600px) {
  .dl-appearance { gap: 4px; }
  .dl-appearance .dl-button { padding: 0 10px; }
}

/* ---------- index ---------- */

.dl-index { padding: var(--dl-pad); padding-top: calc(var(--dl-pad) + var(--dl-logo-h) + clamp(40px, 7vw, 96px)); max-width: 1320px; }
.dl-index__body { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: clamp(32px, 4vw, 64px); align-items: start; }
.dl-index__designs { min-width: 0; }

/* Style guide card: the right column on desktop, its own section on a phone. */
.dl-guide { position: sticky; top: calc(var(--dl-pad) + var(--dl-logo-h) + 24px); }
.dl-guide__card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 22px;
  border: 1px solid var(--dl-rule);
  border-radius: 18px;
  text-decoration: none;
  transition: background-color .12s ease-out;
}
.dl-guide__card:hover { background: var(--dl-paper-sunk); }
.dl-guide__title { font: 600 20px/1.2 var(--dl-font); letter-spacing: -.01em; }
.dl-guide__text { color: var(--dl-ink-secondary); }
.dl-guide__go { font-weight: 600; margin-top: 4px; }
.dl-index__head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 16px 32px; margin-bottom: clamp(20px, 3vw, 40px); }
.dl-index h1 { font: var(--dl-t-display); letter-spacing: -.02em; margin: 0; }

.dl-list { list-style: none; margin: 0; padding: 0; }
.dl-list + .dl-list { margin-top: 12px; border-top: 1px solid var(--dl-rule); padding-top: 12px; }
.dl-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 20px;
  padding: 14px 20px;
  margin-left: -20px;
  border-radius: 14px;
  text-decoration: none;
  transition: background-color .12s ease-out;
}
.dl-row:hover, .dl-row:focus-visible { background: var(--dl-paper-sunk); }
.dl-row__text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.dl-row__title { font-weight: 600; letter-spacing: -.01em; }
.dl-row__summary { color: var(--dl-ink-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-row__by { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dl-row__side { text-align: right; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }

/* Thumbnail: the start screen, live, in a tiny black phone frame. The screen
   is 402 x 874 scaled to 60 wide; the bezel is 3px all round. */
.dl-thumb {
  --k: calc(60 / 402);
  --bezel: 3px;
  position: relative;
  box-sizing: content-box;
  width: 60px;
  height: calc(874px * var(--k));
  padding: var(--bezel);
  border-radius: 12px;
  background: #0a0a0a;
  box-shadow: 0 1px 0 rgba(255,255,255,.14) inset, 0 8px 16px -10px rgba(20, 18, 15, .5);
  flex: none;
}
.dl-thumb__screen {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 9px;
  overflow: hidden;
  background: #000;
}
.dl-thumb iframe {
  position: absolute;
  top: 0; left: 0;
  width: 402px;
  height: 874px;
  border: 0;
  transform: scale(var(--k));
  transform-origin: top left;
  pointer-events: none;
}

/* Creator: avatar and name. */
.dl-creator { display: inline-flex; align-items: center; gap: 6px; }
.dl-avatar { width: 20px; height: 20px; border-radius: 999px; object-fit: cover; flex: none; background: var(--dl-rule); }
.dl-avatar--initials { display: inline-grid; place-items: center; font: 600 9px/1 var(--dl-font); color: var(--dl-ink-secondary); letter-spacing: .02em; }
.dl-byline { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dl-byline .dl-avatar { width: 24px; height: 24px; }

/* Top right: the page's actions, then the signed-in person. On the same
   centre line as the logo. */
.dl-actions {
  position: fixed;
  top: calc(var(--dl-pad) + var(--dl-logo-h) / 2 - 20px);
  right: var(--dl-pad);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
}
.dl-me { position: relative; }
.dl-me[hidden] { display: none; }

/* Share: copies the link to the page. */
.dl-share { height: 40px; padding: 0 16px; background: var(--dl-paper); }
.dl-share[data-copied] { background: var(--dl-ink); border-color: var(--dl-ink); color: var(--dl-paper); }
.dl-me__button {
  width: 40px; height: 40px;
  padding: 0; border: 0; border-radius: 999px;
  overflow: hidden; cursor: pointer;
  background: var(--dl-paper-sunk);
  box-shadow: 0 0 0 1px var(--dl-rule);
  display: grid; place-items: center;
  font: 600 14px/1 var(--dl-font); color: var(--dl-ink-secondary);
}
.dl-me__button img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dl-me__menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 220px; padding: 14px 16px;
  background: var(--dl-paper);
  border: 1px solid var(--dl-rule);
  border-radius: 14px;
  box-shadow: 0 18px 40px -18px rgba(20, 18, 15, .4);
  display: flex; flex-direction: column; gap: 2px;
}
.dl-me__menu[hidden] { display: none; }
.dl-me__name { margin: 0; font-weight: 600; }
.dl-me__menu .dl-meta { margin: 0 0 10px; }
.dl-me__out { padding-top: 10px; border-top: 1px solid var(--dl-rule); text-decoration: none; font-weight: 500; }
.dl-me__out:hover { text-decoration: underline; }
.dl-tag { font: var(--dl-t-micro); color: var(--dl-ink-secondary); border: 1px solid var(--dl-rule); border-radius: 999px; padding: 5px 9px; }
.dl-empty { color: var(--dl-ink-secondary); padding: 18px 0; }

/* ---------- design page ----------
 * One slide: title, author and summary left, one device right. People click
 * through the prototype inside the device. */

.dl-design {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--dl-gap);
  /* Extra room on the right moves the device left, clear of the share
     button in the top right corner. */
  padding: 0 calc(var(--dl-pad) + 96px) 0 var(--dl-pad);
  min-height: 100svh;
}

.dl-copy {
  /* The same space above and below, so the copy sits at the vertical centre
     and clears the logo at the top and the variant tabs at the bottom. */
  padding: calc(var(--dl-pad) + var(--dl-logo-h) + 40px) 0;
  max-width: 50ch;
  display: flex;
  flex-direction: column;
  gap: 22px;
  align-self: center;
}
.dl-copy h1 { font: var(--dl-t-display); letter-spacing: -.02em; margin: 0; text-wrap: balance; }
.dl-copy > * { margin: 0; }

/* Variant tabs, fixed in the bottom left corner like the logo in the top
   left. Each tab is a link to that variant's page; the current one is filled
   with ink. */
.dl-variants {
  position: fixed;
  left: var(--dl-pad);
  bottom: var(--dl-pad);
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: calc(50vw - var(--dl-pad) - var(--dl-gap) / 2);
}
.dl-variants__tab {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--dl-rule);
  border-radius: 999px;
  font: 500 14px/1 var(--dl-font);
  color: var(--dl-ink-secondary);
  text-decoration: none;
  transition: background-color .12s ease-out, border-color .12s ease-out, color .12s ease-out;
}
.dl-variants__tab:hover { background: var(--dl-paper-sunk); color: var(--dl-ink); }
.dl-variants__tab[aria-current="page"] { background: var(--dl-ink); border-color: var(--dl-ink); color: var(--dl-paper); }

.dl-stage {
  position: sticky;
  top: 0;
  height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: calc(var(--dl-pad) * .6) 0;
  min-width: 0;
}
.dl-stage__fit { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
/* ---------- device frame ----------
 * iPhone 17 Pro, 402 x 874pt, drawn as in the studio. The frame draws body, bezel,
 * island and home indicator. The status bar belongs to the screen. */

device-frame {
  --frame-screen-w: 402px;
  --frame-screen-h: 874px;
  --frame-bezel: 12px;
  --frame-w: calc(var(--frame-screen-w) + var(--frame-bezel) * 2);
  --frame-h: calc(var(--frame-screen-h) + var(--frame-bezel) * 2);
  --frame-scale: 1;
  display: block;
  flex: none;
  width: calc(var(--frame-w) * var(--frame-scale));
  height: calc(var(--frame-h) * var(--frame-scale));
}
device-frame .frame {
  position: relative;
  width: var(--frame-w);
  height: var(--frame-h);
  transform: scale(var(--frame-scale));
  transform-origin: top left;
  background: #0a0a0a;
  border-radius: 67px;
  padding: var(--frame-bezel);
  box-shadow:
    0 1px 0 rgba(255,255,255,.14) inset,
    0 32px 64px -24px rgba(20,18,15,.45),
    0 4px 12px -4px rgba(20,18,15,.25);
}
device-frame .frame__screen {
  position: absolute;
  top: var(--frame-bezel);
  left: var(--frame-bezel);
  width: var(--frame-screen-w);
  height: var(--frame-screen-h);
  border: 0;
  border-radius: 55px;
  display: block;
  background: #000;
  color-scheme: dark;
}
device-frame .frame__screen[hidden] { display: none; }
/* frame.js loads the next screen behind the current one, then fades it in. */
device-frame .frame__screen.is-loading { opacity: 0; pointer-events: none; }
device-frame .frame__screen.is-entering { animation: frame-screen-in 180ms ease-out; }
@keyframes frame-screen-in { from { opacity: 0; } }
device-frame .frame__island {
  position: absolute;
  top: calc(var(--frame-bezel) + 11px);
  left: 50%;
  transform: translateX(-50%);
  width: 126px; height: 37px;
  border-radius: 999px;
  background: #000;
  pointer-events: none;
  z-index: 2;
}
device-frame[data-theme="dark"] .frame__home { background: rgba(255,255,255,.85); }
device-frame .frame__home {
  position: absolute;
  bottom: calc(var(--frame-bezel) + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 140px; height: 5px;
  border-radius: 999px;
  background: rgba(0,0,0,.85);
  pointer-events: none;
  z-index: 2;
}

/* ---------- catalog ---------- */

.dl-catalog { padding: var(--dl-pad); padding-top: calc(var(--dl-pad) + var(--dl-logo-h) + clamp(40px, 7vw, 96px)); max-width: 1240px; }
.dl-catalog > h1 { font: var(--dl-t-display); letter-spacing: -.02em; margin: 0 0 16px; }
.dl-catalog > .dl-lede { max-width: 60ch; margin-bottom: clamp(28px, 4vw, 56px); }
.dl-toc { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 clamp(28px, 4vw, 56px); padding: 0; list-style: none; font: var(--dl-t-caption); }
.dl-toc a { color: var(--dl-ink-secondary); }
.dl-family { font: var(--dl-t-h2); letter-spacing: -.015em; margin: clamp(40px, 5vw, 72px) 0 20px; }
.dl-cat {
  display: grid;
  grid-template-columns: 402px minmax(0, 1fr);
  gap: 20px 40px;
  padding: 28px 0;
  border-top: 1px solid var(--dl-rule);
  scroll-margin-top: 24px;
}
.dl-cat__demo { width: 402px; border: 0; border-radius: 20px; background: transparent; display: block; min-height: 80px; }
.dl-cat__info { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.dl-cat__info h3 { font: 600 20px/1.2 var(--dl-font); margin: 0; }
.dl-cat__info p { margin: 0; color: var(--dl-ink-secondary); }
.dl-cat__code {
  margin: 0;
  max-height: 340px;
  overflow: auto;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--dl-paper-sunk);
  font: 12px/1.55 "SFMono-Regular", Consolas, Menlo, monospace;
  white-space: pre;
  tab-size: 2;
}

/* ---------- login ---------- */

.dl-login { min-height: 100svh; display: grid; place-items: center; padding: var(--dl-pad); }
.dl-login__box { display: flex; flex-direction: column; align-items: center; gap: 40px; width: min(340px, 100%); }
.dl-login__box > .dl-button { align-self: stretch; }
.dl-login__box > .dl-meta { margin: -24px 0 0; text-align: center; }
/* The nell lockup above "designlab", set so its x-height matches the wordmark. */
.dl-login__mark { display: flex; flex-direction: column; align-items: center; gap: .3em; margin: 0; font: 600 min(44px, 6.6vw)/1 var(--dl-font); }
.dl-login__mark svg { height: 1em; width: auto; display: block; }
.dl-login__mark span { font-size: 1.3em; line-height: .75; letter-spacing: -.02em; }
.dl-button--primary { height: 44px; justify-content: center; background: var(--dl-ink); color: var(--dl-paper); border-color: var(--dl-ink); }
.dl-button--primary:hover { background: var(--dl-ink); opacity: .85; }

/* ---------- narrow viewports ----------
 * Device first, at the width of the phone, then the copy. As in the studio. */

@media (max-width: 820px) {
  :root {
    --dl-pad: 20px;
    --dl-gap: 8px;
    --dl-logo-h: 26px;
    --dl-t-display: 600 clamp(28px, 8vw, 40px)/1.08 var(--dl-font);
  }
  .dl-logo { position: absolute; }
  .dl-design { grid-template-columns: minmax(0, 1fr); }
  .dl-stage {
    position: relative;
    order: -1;
    height: auto;
    padding: calc(var(--dl-pad) + var(--dl-logo-h) + 16px) 0 0;
  }
  .dl-stage { gap: 12px; }
  .dl-stage__fit { flex: none; height: min(74svh, 700px); }
  .dl-design { padding: 0 var(--dl-pad); }
  /* On a phone the copy is centred under the device, and the tabs sit
     between the device and the title. */
  .dl-copy { padding: 12px 0 var(--dl-pad); max-width: 50ch; margin: 0 auto; align-self: start; align-items: center; text-align: center; }
  .dl-byline { justify-content: center; }
  .dl-variants { position: static; max-width: none; padding-top: 16px; justify-content: center; }
  .dl-copy { order: 1; }
  .dl-row__side { display: none; }
  .dl-row { grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; }
  .dl-actions { position: absolute; }
  .dl-share { height: 36px; padding: 0 14px; }
  .dl-index__body { grid-template-columns: minmax(0, 1fr); }
  .dl-guide { position: static; padding-top: 12px; }
  .dl-cat { grid-template-columns: minmax(0, 1fr); }
  .dl-cat__demo { width: 100%; max-width: 402px; }
}
