/* Base components: page shell, top bar, button, text field, form error, notice,
   empty state, confirmation dialog, frame. No transition and no animation anywhere:
   a state change is immediate. */

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

[hidden] { display: none !important; }

html {
  font-family: var(--font);
  font-size: 100%;
  line-height: var(--leading);
  color: var(--ink);
  background: var(--surface);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body { margin: 0; min-height: 100vh; }

h1, h2, p, ul, ol, form { margin: 0 0 var(--space-4); }
h1 { font-size: var(--text-3); line-height: var(--leading-tight); font-weight: 600; overflow-wrap: anywhere; }
h2 { font-size: var(--text-2); line-height: var(--leading-tight); font-weight: 600; margin-top: var(--space-8); }

a { color: var(--ink); text-decoration: underline; text-underline-offset: 0.15em; }

/* Focus: a 2px ink outline on every interactive element, never removed. */
:focus-visible { outline: var(--focus) solid var(--ink); outline-offset: var(--focus); }
h1:focus, main:focus, .error:focus, .notice:focus { outline: var(--focus) solid var(--ink); outline-offset: var(--focus); }

/* Page shell */
.skip { position: absolute; left: var(--space-4); top: -100vh; padding: var(--space-2) var(--space-3); background: var(--surface); }
.skip:focus { top: var(--space-2); }

main { display: block; padding: var(--space-8) var(--space-4) var(--space-12); max-width: 72rem; margin: 0 auto; }
.column { max-width: var(--column); }

/* Top bar */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--space-2) var(--space-6);
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--rule) solid var(--line);
}
.topbar p { margin: 0; }
.topbar-name { font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.topbar-person { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); min-width: 0; }
.topbar-email { color: var(--ink-2); overflow-wrap: anywhere; min-width: 0; }
.topbar-person a { display: inline-flex; align-items: center; min-height: var(--control); }

/* Banner: the limits of an emailed-link session */
.banner { padding: var(--space-4); background: var(--surface-2); border-bottom: var(--rule) solid var(--line); }
.banner p { max-width: 44rem; }
.banner p:last-child { margin-bottom: 0; }

/* Button: primary is solid ink, secondary is outlined */
.button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--control); padding: var(--space-2) var(--space-4);
  font: inherit; font-weight: 600; line-height: var(--leading-tight); text-align: center; text-decoration: none;
  color: var(--ink); background: var(--surface);
  border: var(--rule-strong) solid var(--ink); border-radius: var(--radius);
  cursor: pointer; max-width: 100%;
}
.button.primary { color: var(--surface); background: var(--ink); }
.button:disabled { color: var(--ink-2); background: var(--surface-2); border-color: var(--line); cursor: not-allowed; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-4); }

/* Text field, always with a visible label */
label { display: block; font-weight: 600; margin-bottom: var(--space-1); }
input[type="email"], input[type="text"] {
  display: block; width: 100%; min-height: var(--control); padding: var(--space-2) var(--space-3);
  font: inherit; color: var(--ink); background: var(--surface);
  border: var(--rule) solid var(--ink-2); border-radius: var(--radius);
  margin-bottom: var(--space-4);
}
.check { display: flex; align-items: center; gap: var(--space-3); min-height: var(--control); }
.check input { width: 1.5rem; height: 1.5rem; margin: 0; flex: none; accent-color: var(--ink); }
.check label { margin: 0; font-weight: 400; }

/* Form error: ink, bold, a 2px left rule, prefixed "Error:" in the markup */
.error { font-weight: 600; border-left: var(--rule-strong) solid var(--ink); padding: var(--space-2) var(--space-3); margin: 0 0 var(--space-4); }

/* Notice: something happened, stated plainly */
.notice { border-left: var(--rule-strong) solid var(--line); padding: var(--space-2) var(--space-3); margin: 0 0 var(--space-4); }
.notice p:last-child { margin-bottom: 0; }

/* Empty state */
.empty { color: var(--ink-2); padding: var(--space-8) 0; }

/* Chooser */
.choices { list-style: none; padding: 0; border-top: var(--rule) solid var(--line); }
.choices li { border-bottom: var(--rule) solid var(--line); }
.choices a { display: flex; align-items: center; min-height: var(--control); padding: var(--space-2) 0; overflow-wrap: anywhere; }

/* Recovery codes */
.codes { list-style: none; padding: var(--space-4); background: var(--surface-2); display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: var(--space-2) var(--space-6); }
.codes li { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }

/* Confirmation: the native dialog; the server-rendered confirm page is the
   no-script path */
dialog { width: min(var(--column), calc(100vw - var(--space-8))); padding: var(--space-6); color: var(--ink); background: var(--surface); border: var(--rule-strong) solid var(--ink); border-radius: var(--radius); }
dialog::backdrop { background: rgb(17 17 17 / 0.4); }
dialog h2 { margin-top: 0; }
dialog form { margin: 0; }

/* Frame: a square on the frame ground; the image is contained, never cropped.
   Defined for the archive screens. */
.frame { aspect-ratio: 1 / 1; background: var(--frame); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.frame img { max-width: 100%; max-height: 100%; width: 100%; height: 100%; object-fit: contain; display: block; }

@media print {
  .topbar, .banner, .skip, .no-print, dialog { display: none !important; }
  main { padding: 0; }
  .codes { background: none; padding: 0; }
}
