/* Somo stylesheet. Values come from architecture section 9 and the mockup.
   Square corners everywhere, 1px ink rules, no shadows or gradients.
   Templates use classes only: the content security policy forbids inline styles. */

:root {
  --paper: #E9DEC5;
  --panel: rgba(243, 235, 216, 0.82);
  --field: #F3EBD8;
  --ink: #1C1712;
  --muted: #3D3327;
  --link: #17365C;
  --danger: #6E1C10;
  --rule: 1px solid var(--ink);
  --rule-soft: 1px solid rgba(28, 23, 18, 0.35);
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

/* Fonts: served by Somo, Latin subset, 400 and 600. */
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-sans-latin-400.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/ibm-plex-sans-latin-600.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-mono-latin-400.woff2) format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 600; font-display: swap; src: url(fonts/ibm-plex-mono-latin-600.woff2) format("woff2"); }

/* ---------- Base ---------- */

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background-color: var(--paper);          /* readable before the tile arrives */
  background-image: url(paper.jpg);
  background-repeat: repeat;
  background-size: 1024px 1024px;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.4;
}
body.student { font-size: 16px; }

h1, h2, h3, p, ul, ol { margin: 0; }
h1 { font-size: 28px; font-weight: 600; line-height: 1.15; }
h2 { font-size: 20px; font-weight: 600; line-height: 1.2; }
ul.file-list { list-style: none; padding: 0; }

a { color: var(--ink); }
a:hover { color: var(--link); }

:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

img, svg { border-radius: 0; }

/* Mono labels: 11–13px capitals with 0.1em spacing. */
.label {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.meta { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

.wordmark {
  vertical-align: top;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.1em;
}
.wordmark svg { width: 20px; height: 20px; flex: none; }
.tag {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  border: var(--rule);
  padding: 2px 6px;
}

/* ---------- Surfaces ---------- */

.panel { border: var(--rule); background: var(--panel); padding: 20px 16px; }
.panel.notice { display: flex; flex-direction: column; gap: 10px; }
.prose p + p { margin-top: 0.75em; }
/* Danger red sits on panels only, never straight on the texture. */
.panel .danger, .panel.danger-text { color: var(--danger); }

/* ---------- Controls ---------- */

.button, button, input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 16px;
  border: var(--rule);
  border-radius: 0;
  background: var(--ink);
  color: var(--field);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.button:hover, button:hover { color: #FFFFFF; }
.button.secondary, button.secondary { background: rgba(243, 235, 216, 0.8); color: var(--ink); font-weight: 400; }
.button.secondary:hover, button.secondary:hover { color: var(--link); }
.button.danger, button.danger { background: transparent; border-color: var(--danger); color: var(--danger); font-weight: 400; }
.button.small, button.small { min-height: 32px; padding: 4px 10px; font-size: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

input[type="text"], input[type="password"], input[type="date"], input[type="number"], select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: var(--rule);
  border-radius: 0;
  background: var(--field);
  color: var(--ink);
  font: inherit;
}

input[type="checkbox"], input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  display: inline-block;
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0;
  border: 1.5px solid var(--ink);
  border-radius: 0;
  background: transparent;
  vertical-align: middle;
}
/* A ticked box shows a tick; a chosen radio button a filled square. */
input[type="checkbox"]:checked {
  background: var(--field) url(tick.svg) center / 14px 14px no-repeat;
}
input[type="radio"]:checked {
  background: var(--ink);
  box-shadow: inset 0 0 0 3px var(--field);
}
input[type="checkbox"], input[type="radio"] { cursor: pointer; }

/* ---------- Tables (admin) ---------- */

/* No overflow clipping: row menus open below their button. Narrow screens
   drop the date column instead of scrolling. */
.table-box { border: var(--rule); background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th {
  padding: 10px 12px;
  border-bottom: var(--rule);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
}
td { padding: 13px 12px; }
tbody tr + tr { border-top: var(--rule-soft); }
td.num, th.num { text-align: right; }
td.num, td.date { font-family: var(--mono); font-size: 13px; white-space: nowrap; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ---------- Student pages: one column, at most 480px ---------- */

.student .column {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.student .bar { padding-bottom: 12px; border-bottom: 2px solid var(--ink); }
.student .wordmark { font-size: 15px; gap: 7px; }
.student .wordmark svg { width: 18px; height: 18px; }
.stack { display: flex; flex-direction: column; gap: 22px; }
.title-block { display: flex; flex-direction: column; gap: 6px; }

.file-list { display: flex; flex-direction: column; gap: 10px; }
.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: var(--rule);
  background: rgba(243, 235, 216, 0.86);
}
.file-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.file-name { overflow-wrap: anywhere; }
.file-row .button { flex: none; padding: 0 14px; color: var(--field); }

/* ---------- Admin pages ---------- */

.admin-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding: 14px 24px;
  border-bottom: 2px solid var(--ink);
}
.admin-header .brand { display: flex; align-items: center; gap: 12px; }
.admin-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; }
.admin-nav a { text-decoration: none; }
.admin-nav a[aria-current="page"] {
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 2px;
}
.admin-nav form { display: inline; margin: 0; }
.admin-nav button { min-height: 0; padding: 0; border: 0; background: none; color: var(--ink); font-weight: 400; }
.admin-nav button:hover { color: var(--link); }

.admin-body { display: grid; grid-template-columns: 250px minmax(0, 1fr); flex: 1 0 auto; }
.tree { padding: 20px 12px 20px 16px; border-right: var(--rule); display: flex; flex-direction: column; gap: 16px; }
.tree .label { font-size: 11px; padding-left: 8px; }
.tree-rows { display: flex; flex-direction: column; gap: 2px; }
.tree-row { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 4px 8px; color: var(--ink); text-decoration: none; }
.tree-row .marker { font-family: var(--mono); width: 12px; }
.tree-row[aria-current="true"] { background: var(--ink); color: var(--field); font-weight: 600; }
.content { min-width: 0; padding: 20px 28px 32px; display: flex; flex-direction: column; gap: 18px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.toolbar .meta { margin-left: auto; }
.dropzone { border: 1px dashed var(--ink); padding: 22px 16px; text-align: center; color: var(--muted); font-size: 14px; }

.signin { display: flex; justify-content: center; padding: 96px 24px 48px; }
.signin form { width: 100%; max-width: 400px; padding: 28px 28px 32px; display: flex; flex-direction: column; gap: 20px; }
.signin h1 { font-size: 26px; line-height: 1.2; }

/* ---------- Phase 2 and 3: admin screens ---------- */

[hidden] { display: none !important; }

.admin-header .wordmark { text-decoration: none; color: var(--ink); }

button[disabled] { opacity: 0.45; cursor: not-allowed; }
.button.dashed, button.dashed {
  background: transparent; color: var(--ink); font-weight: 400;
  border: 1px dashed var(--ink); min-height: 40px; font-size: 14px;
}
button.wide { width: 100%; }
form.inline { display: inline; margin: 0; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend, .field p.label {
  padding: 0; margin-bottom: 4px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted);
}
.danger { color: var(--danger); }
.small-print { font-size: 13px; }

/* Disclosure menus (no script needed): the summary is the button. */
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
.pop { position: relative; display: inline-block; }
.pop-box {
  position: absolute; z-index: 10; top: calc(100% + 6px); left: 0;
  width: 300px; max-width: calc(100vw - 32px);
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px; border: var(--rule); background: var(--field);
}
.pop-box.right { left: auto; right: 0; }
.pop-box form { display: flex; flex-direction: column; gap: 8px; }
.pop-box form + form { padding-top: 12px; border-top: var(--rule-soft); }
.pop-box button { align-self: flex-start; }

/* Tree: nested <details>; + and − markers come from the open state. */
.tree-row a { color: inherit; text-decoration: none; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tree-row a:hover { text-decoration: underline; }
summary.tree-row { cursor: pointer; }
.tree-row .marker::before { content: ""; }
details.tree-branch > summary .marker::before { content: "+"; }
details.tree-branch[open] > summary .marker::before { content: "\2212"; }
.tree-children { padding-left: 16px; display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.tree-branch.top > summary, .tree-row.leaf.top { font-weight: 600; }
.tree-row.current { background: var(--ink); color: var(--field); font-weight: 600; }
.tree .new-top { margin-left: 8px; }

.crumbs { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--link); text-decoration: underline; }

.notice-line { border: var(--rule); background: var(--panel); padding: 10px 14px; }
.notice-line.error { color: var(--danger); border-color: var(--danger); }

.toolbar form { margin: 0; }
.upload-status { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; }
progress {
  appearance: none; -webkit-appearance: none;
  width: 100%; height: 10px; border: var(--rule); background: var(--field);
}
progress::-webkit-progress-bar { background: var(--field); }
progress::-webkit-progress-value { background: var(--ink); }
progress::-moz-progress-bar { background: var(--ink); }
.dropzone.active { background: var(--panel); color: var(--ink); border-style: solid; }

th.tick, td.tick { width: 44px; padding-right: 0; }
td.actions { text-align: right; white-space: nowrap; }
td.actions > * { margin-left: 6px; vertical-align: middle; }
td.actions .pop { text-align: left; white-space: normal; }
/* Long names with no spaces (Some_Long_Name.pptx) wrap rather than widen
   the table past its box and under the create-link panel. */
td.name { overflow-wrap: anywhere; }
/* The table answers to its own width, which the create-link panel narrows,
   not to the window: drop the date column, then stack Edit over Remove. */
.table-box { container: files / inline-size; }
@container files (max-width: 640px) {
  .date-col { display: none; }
}
@container files (max-width: 520px) {
  td.actions { white-space: normal; }
  td.actions > * { display: block; margin: 0 0 6px auto; width: max-content; }
  td.actions > *:last-child { margin-bottom: 0; }
  td.actions form.inline > button { margin: 0; }
}
.folder-link { font-weight: 600; }
.file-link { text-decoration: none; }
.file-link:hover { text-decoration: underline; }

/* Create-link panel: a third column beside the folder content. */
.admin-body.with-panel { grid-template-columns: 250px minmax(0, 1fr) 360px; }
.link-panel {
  padding: 20px 24px 32px; border-left: var(--rule); background: var(--panel);
  display: flex; flex-direction: column; gap: 20px;
}
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.panel-form { display: flex; flex-direction: column; gap: 20px; }
.item-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice { display: flex; align-items: center; gap: 12px; cursor: pointer; }
/* The choices are labels inside a .field, but read as text (mockup). */
.field label.choice { font-family: var(--sans); font-size: 15px; letter-spacing: 0; text-transform: none; color: var(--ink); }
/* Custom hours and custom date: the choice with its field beside it. */
.choice-row { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 12px; align-items: center; }
.link-ready {
  border: var(--rule); background: var(--field); padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.link-url { font-family: var(--mono); font-size: 14px; overflow-wrap: anywhere; user-select: all; }
.link-ready button.copy { align-self: flex-start; color: var(--link); font-weight: 600; }

/* QR code of a new link; full screen for showing it to a class. */
.qr-stage .qr { width: 100%; max-width: 240px; }
.qr-caption { display: none; }
.qr-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.qr-stage:fullscreen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3vh; padding: 24px; background: var(--paper); cursor: zoom-out;
}
.qr-stage:fullscreen .qr { width: min(78vh, 92vw); max-width: none; }
.qr-stage:fullscreen .qr-caption {
  display: block; max-width: 92vw; text-align: center; overflow-wrap: anywhere;
  font-family: var(--mono); font-size: clamp(16px, 2.4vw, 30px);
}
.qr-stage::backdrop { background: var(--paper); }

/* Build stamp at the foot of signed-in admin pages. */
body.admin { display: flex; flex-direction: column; }
.build-stamp { margin-top: auto; padding: 12px 24px 16px; border-top: var(--rule); text-align: right; }
.build-stamp .meta { font-size: 11px; letter-spacing: 0.04em; }

/* Full-width admin pages: links list, link detail, confirmations. */
.page { max-width: 1100px; padding: 24px 28px 40px; display: flex; flex-direction: column; gap: 20px; }
.page .notice { max-width: 640px; }
.facts { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.facts form { margin-top: 6px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.tag.state-active { background: var(--ink); color: var(--field); }
.tag.state-revoked, .tag.state-expired { color: var(--danger); border-color: var(--danger); background: var(--field); }

/* Security page (mockup "Admin — 2FA setup"). */
.page.centered { max-width: 880px; margin: 0 auto; width: 100%; }
.panel.security { padding: 28px 28px 32px; display: flex; flex-direction: column; gap: 18px; }
.panel.security hr { width: 100%; margin: 4px 0; border: 0; border-top: var(--rule); }
.panel.security .panel-head { align-items: center; }
.tag.status { font-size: 12px; padding: 6px 12px; letter-spacing: 0.1em; flex: none; }
.qr-row { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 24px; align-items: start; }
.qr { border: var(--rule); background: var(--field); line-height: 0; }
.qr svg { display: block; width: 100%; height: auto; }
.setup-key {
  border: 1px dashed var(--ink); padding: 14px 16px;
  font-family: var(--mono); font-size: 17px; letter-spacing: 0.08em;
  overflow-wrap: anywhere; user-select: all;
}
.code-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
.code-input { font-family: var(--mono); font-size: 18px; letter-spacing: 0.2em; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.signin form .muted { margin-top: -8px; }

/* Student extras */
.group { display: flex; flex-direction: column; gap: 10px; }
.panel.gone { margin-top: 15vh; }
.panel.gone h1 { font-size: 26px; }

@media (max-width: 1100px) {
  .admin-body.with-panel { grid-template-columns: 250px minmax(0, 1fr); }
  .link-panel { grid-column: 2; border-left: 0; border-top: var(--rule); }
}

/* Under 700px the tree stacks above the content. */
@media (max-width: 700px) {
  .admin-body, .admin-body.with-panel { grid-template-columns: minmax(0, 1fr); }
  .link-panel { grid-column: 1; }
  .date-col { display: none; }
  .page { padding: 20px 16px 28px; }
  .tree { border-right: 0; border-bottom: var(--rule); }
  .content { padding: 20px 16px 28px; }
  .signin { padding-top: 48px; }
  .panel.security { padding: 20px 16px 24px; }
  .qr-row, .pair, .code-row { grid-template-columns: minmax(0, 1fr); }
  .qr { max-width: 240px; }
  .build-stamp { padding: 12px 16px 16px; text-align: left; }
}
