@font-face { font-family: "IBM Plex Sans"; src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }

/* Permute's own palette: near-black with a lime signal colour. Dark is the default. */
:root {
  --bg: #0d0d0c;
  --s1: #161615;
  --s2: #1e1e1d;
  --b1: #2a2a28;
  --b2: #3a3a38;
  --t1: #e8e8e3;
  --t2: #8a8a84;
  --t3: #5c5c57;
  --ac: #c8f04a;
  --ac-hover: #b4dc36;
  --ac-ink: #0d0d0c;
  --ac-wash: rgba(200, 240, 74, .08);
  --ok: #3fd68a;
  --er: #f05050;

  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --say: clamp(1.55rem, 1.05rem + 1.6vw, 2.3rem);
  --gutter: clamp(1rem, .5rem + 2vw, 2rem);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f3ef;
  --s1: #ffffff;
  --s2: #eceae6;
  --b1: #dcdad4;
  --b2: #c4c2bb;
  --t1: #111110;
  --t2: #5f5e57;
  --t3: #8f8d85;
  --ac: #4a6800;
  --ac-hover: #385000;
  --ac-ink: #ffffff;
  --ac-wash: rgba(74, 104, 0, .07);
  --ok: #1a7a46;
  --er: #c82020;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--t1);
  font: 400 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: inherit; text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { color: var(--ac); }
:focus-visible { outline: 2px solid var(--ac); outline-offset: 2px; border-radius: 4px; }

.page {
  max-width: 60rem;
  margin: 0 auto;
  padding: 0 var(--gutter);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }

/* ── Header ─────────────────────────────────────────────────────────────── */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.1rem 0; border-bottom: 1px solid var(--b1);
}
.wordmark { display: flex; align-items: center; gap: .6rem; text-decoration: none; }
.wordmark:hover { color: inherit; }
.wordmark img { inline-size: 26px; block-size: 26px; display: block; }
.wordmark span { font: 500 1rem/1 var(--mono); letter-spacing: -0.02em; }
.top-right { display: flex; align-items: center; gap: .75rem; }
.pill {
  display: inline-flex; align-items: center; gap: .4rem;
  font: 400 .6875rem/1 var(--mono); color: var(--t2);
  background: var(--s1); border: 1px solid var(--b1); border-radius: 999px; padding: .4rem .7rem;
  white-space: nowrap;
}
.pill svg { inline-size: .7rem; block-size: .7rem; fill: none; stroke: var(--ac); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.theme {
  inline-size: 30px; block-size: 30px; display: grid; place-items: center;
  border: 1px solid var(--b2); border-radius: 50%; background: var(--s1); color: var(--t2); cursor: pointer;
  transition: border-color .15s, color .15s;
}
.theme:hover { border-color: var(--ac); color: var(--ac); }
.theme svg { inline-size: 14px; block-size: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.theme svg path { fill: currentColor; stroke: none; }

/* ── The sentence ───────────────────────────────────────────────────────── */
.stage { padding: clamp(2.25rem, 6vh, 3.75rem) 0 2rem; }
.say {
  margin: 0;
  font-size: var(--say);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.028em;
}
.say-turn { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: .26em; row-gap: .1em; }
.say-turn .w { white-space: nowrap; }
.w { display: inline-block; }
.w-soft { font-weight: 400; color: var(--t2); }
.w-subject { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

.blank { border-bottom: 2px solid currentColor; padding-bottom: .02em; }
label.blank { color: var(--ac); cursor: pointer; }
label.blank:hover { color: var(--ac-hover); }
.blank-idle { color: var(--t3); border-bottom: 2px dashed var(--b2); font-weight: 400; }

.lede { max-width: 36rem; margin: 1.25rem 0 0; color: var(--t2); }
.intro-actions { display: flex; align-items: center; gap: 1rem; margin-top: 1.75rem; flex-wrap: wrap; }
.hint { color: var(--t3); font: 400 .75rem/1.4 var(--mono); }

.work { position: relative; z-index: 5; } /* keeps the format menu above the file list */
.pick { position: relative; display: inline-block; }
.pick-btn {
  font: inherit; letter-spacing: inherit; color: var(--ac);
  display: inline-flex; align-items: center; gap: .28em;
  background: transparent; border: 0; border-radius: 0; margin: 0; padding: 0 0 .02em;
  border-bottom: 2px solid currentColor;
  cursor: pointer; white-space: nowrap;
}
.pick-btn:hover { color: var(--ac-hover); }
.pick-btn:disabled { cursor: default; color: var(--t3); }
.pick-btn svg { inline-size: .42em; block-size: .3em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s ease; }
.pick-btn[aria-expanded="true"] svg { transform: rotate(180deg); }

/* The menu is set in body type, never at headline size. */
.menu {
  position: absolute; top: calc(100% + .5rem); left: 0; z-index: 40;
  min-inline-size: 13rem; max-block-size: min(22rem, 60vh); overflow-y: auto;
  margin: 0; padding: .3rem; list-style: none;
  background: var(--s1); border: 1px solid var(--b2); border-radius: 8px;
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, .45);
  font: 400 .875rem/1.2 var(--sans); letter-spacing: 0; color: var(--t1);
  animation: menu-in .14s ease-out;
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } }
.menu li {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .5rem .65rem; border-radius: 5px; cursor: pointer; outline: none;
}
.menu li:hover, .menu li:focus { background: var(--b1); }
.menu li[aria-selected="true"] { color: var(--ac); font-weight: 500; }
.menu li[aria-selected="true"]::after {
  content: ""; inline-size: .55rem; block-size: .3rem; margin-top: -.15rem;
  border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg);
}

.work.enter .w { animation: rise .4s cubic-bezier(.2, .7, .2, 1) both; }
.work.enter .w:nth-child(2) { animation-delay: .05s; }
.work.enter .w:nth-child(3) { animation-delay: .1s; }
.work.enter .w:nth-child(4) { animation-delay: .15s; }
@keyframes rise { from { opacity: 0; transform: translateY(.2em); } }

/* ── Options ────────────────────────────────────────────────────────────── */
.opts {
  display: flex; flex-wrap: wrap; gap: .6rem 1.5rem; margin-top: 1.5rem;
  padding: .85rem 1rem; background: var(--s1); border: 1px solid var(--b1); border-radius: 8px;
}
.opts:empty { display: none; }
.opt { display: flex; align-items: center; gap: .5rem; font: 400 .75rem/1 var(--mono); color: var(--t2); }
.opt select {
  font: 400 .8125rem/1 var(--sans); color: var(--t1);
  appearance: none; -webkit-appearance: none;
  background: var(--s2); border: 1px solid var(--b1); border-radius: 5px;
  padding: .4rem 1.7rem .4rem .6rem; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--t2) 50%), linear-gradient(-45deg, transparent 50%, var(--t2) 50%);
  background-size: 4px 4px; background-repeat: no-repeat;
  background-position: right .85rem center, right .6rem center;
}
.opt select:hover { border-color: var(--b2); }
.opt select option { background: var(--s1); }
.opt input[type="range"] { inline-size: 6.5rem; accent-color: var(--ac); }
.opt output { color: var(--t1); min-inline-size: 2.6em; font-variant-numeric: tabular-nums; }
.opt-check { cursor: pointer; color: var(--t1); }
.opt-check input { accent-color: var(--ac); inline-size: .95rem; block-size: .95rem; margin: 0; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin-top: 1.5rem; }
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  font: 600 .875rem/1 var(--sans);
  padding: .7rem 1.1rem; border-radius: 6px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; user-select: none;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn-primary { background: var(--ac); color: var(--ac-ink); }
.btn-primary:hover { background: var(--ac-hover); color: var(--ac-ink); }
.btn-primary:disabled { opacity: .35; cursor: not-allowed; }
.btn-quiet { background: var(--s1); color: var(--t1); border-color: var(--b1); font-weight: 500; }
.btn-quiet:hover { border-color: var(--b2); color: var(--t1); }
.btn-link { background: none; color: var(--t3); font-weight: 500; padding-inline: .6rem; }
.btn-link:hover { color: var(--er); }

/* ── Queue ──────────────────────────────────────────────────────────────── */
.queue { margin-bottom: 3.5rem; }
.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.row {
  position: relative; overflow: hidden;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0 .9rem;
  padding: .6rem .75rem;
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: 7px;
  transition: border-color .2s;
}
.row.done { border-color: color-mix(in srgb, var(--ok) 28%, var(--b1)); }
.row.error, .row.unsupported { border-color: color-mix(in srgb, var(--er) 30%, var(--b1)); }
.row.working { border-color: color-mix(in srgb, var(--ac) 25%, var(--b1)); }
.thumb {
  inline-size: 36px; block-size: 36px; border-radius: 5px; overflow: hidden;
  display: grid; place-items: center; background: var(--s2); border: 1px solid var(--b1);
  font: 500 .5625rem/1 var(--mono); color: var(--t2); letter-spacing: .02em;
}
.thumb img { inline-size: 100%; block-size: 100%; object-fit: cover; display: block; }
.info { min-width: 0; }
.name { display: block; font-size: .8125rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { display: block; font: 400 .6875rem/1.5 var(--mono); color: var(--t3); font-variant-numeric: tabular-nums; }
.meta .note { display: block; color: var(--t2); }
.meta .smaller { color: var(--ok); }
.row.error .meta, .row.unsupported .meta { color: var(--er); }
.row-target select {
  font: 400 .75rem/1 var(--mono); color: var(--t1);
  appearance: none; -webkit-appearance: none;
  background: var(--s2); border: 1px solid var(--b1); border-radius: 4px;
  padding: .35rem 1.5rem .35rem .55rem; cursor: pointer; min-inline-size: 8.5rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--t2) 50%), linear-gradient(-45deg, transparent 50%, var(--t2) 50%);
  background-size: 4px 4px; background-repeat: no-repeat;
  background-position: right .75rem center, right .5rem center;
}
.row-target select option { background: var(--s1); }
.row-end { display: flex; align-items: center; gap: .3rem; justify-content: flex-end; min-inline-size: 6.5rem; }
.state { font: 400 .6875rem/1 var(--mono); color: var(--ac); font-variant-numeric: tabular-nums; }
.save {
  font: 500 .6875rem/1 var(--mono); color: var(--ok);
  background: none; border: 1px solid var(--ok); padding: .4rem .65rem; border-radius: 4px; cursor: pointer;
  white-space: nowrap; transition: background-color .15s, color .15s;
}
.save:hover { background: var(--ok); color: var(--bg); }
.save[data-retry] { color: var(--t2); border-color: var(--b2); }
.save[data-retry]:hover { background: var(--s2); color: var(--t1); }
.remove {
  inline-size: 24px; block-size: 24px; border: 0; border-radius: 4px; background: none; color: var(--t3);
  cursor: pointer; display: grid; place-items: center;
}
.remove:hover { color: var(--er); }
.remove svg { inline-size: 10px; block-size: 10px; stroke: currentColor; stroke-width: 1.6; }
.bar { position: absolute; left: 0; bottom: 0; block-size: 2px; background: var(--ac); inline-size: 0; transition: inline-size .2s linear; }
.row.working .bar.indeterminate { inline-size: 30%; animation: slide 1.1s ease-in-out infinite alternate; }
@keyframes slide { from { left: 0; } to { left: 70%; } }

/* ── Facts ──────────────────────────────────────────────────────────────── */
.facts {
  display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 1.25rem 2.5rem;
  padding: 2.5rem 0; border-top: 1px solid var(--b1);
}
.facts h2 { margin: 0; font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.35; }
.formats { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.4rem 2.5rem; }
.formats dt { font-size: .875rem; font-weight: 500; margin-bottom: .25rem; }
.formats dd { margin: 0; font-size: .8125rem; color: var(--t2); }
.prose { max-width: 38rem; font-size: .875rem; }
.prose p { margin: 0 0 .85rem; }
.prose p:last-child { margin: 0; color: var(--t2); }

.foot {
  display: flex; flex-wrap: wrap; gap: .4rem 1rem; padding: 1.5rem 0 2rem;
  color: var(--t3); font: 400 .6875rem/1.5 var(--mono); border-top: 1px solid var(--b1);
}
.foot a:hover { color: var(--ac); }

/* ── Drag and drop ──────────────────────────────────────────────────────── */
.drop-veil {
  position: fixed; inset: .75rem; pointer-events: none; z-index: 50;
  border: 1.5px dashed var(--ac); border-radius: 12px; background: var(--ac-wash);
  opacity: 0; transition: opacity .15s ease;
}
body.dragging .drop-veil { opacity: 1; }
body.dragging .intro .say { color: var(--ac); }
body.dragging .intro .say .w { color: inherit; border-color: transparent; }

.toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translate(-50%, .5rem);
  background: var(--s2); border: 1px solid var(--b2); color: var(--t1);
  font: 400 .75rem/1.4 var(--mono); padding: .55rem 1rem; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60;
  max-width: calc(100vw - 2rem);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.visually-hidden {
  position: absolute !important; inline-size: 1px; block-size: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ── Small screens ──────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .pill { display: none; }
  .facts { grid-template-columns: 1fr; }
  .formats { grid-template-columns: 1fr; gap: 1.1rem; }
  .row { grid-template-columns: 34px minmax(0, 1fr) auto; gap: .35rem .75rem; }
  .thumb { inline-size: 34px; block-size: 34px; }
  .row-target { grid-column: 2; grid-row: 2; }
  .row-end { grid-column: 3; grid-row: 1 / span 2; min-inline-size: 0; flex-direction: column-reverse; align-items: flex-end; }
}

/* Theme switch: a slow cross-fade of the whole page (View Transitions). */
::view-transition-old(root), ::view-transition-new(root) {
  animation-duration: .55s;
  animation-timing-function: cubic-bezier(.4, 0, .2, 1);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
