/* Marginalia: monospace on warm paper, 1px hairlines, 2px corners, no shadows, one vermilion mark per view */

@font-face {
  font-family: "IBM Plex Mono";
  font-weight: 300;
  font-display: swap;
  src: url("fonts/plex-mono-300.woff2") format("woff2");
}

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

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

:root {
  --paper: #f4f0e8;
  --sheet: #fbf9f5;
  --rule: #dcd5c9;
  --graphite: #6e675e;
  --body: #4a443d;
  --ink: #1d1b18;
  --vermilion: #d2462d;
  --vermilion-text: #b53a23;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.7 "IBM Plex Mono", ui-monospace, monospace;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 460px;
  margin: 0 auto;
  padding: max(40px, env(safe-area-inset-top)) 20px max(32px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 32px;
}

h1, h2 {
  margin: 0;
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1.04;
}

h1 {
  font-size: clamp(34px, 10vw, 44px);
}

h2 {
  font-size: 40px;
}

.mark {
  color: var(--vermilion);
}

.lede {
  margin: 14px 0 0;
  color: var(--body);
  font-size: 14px;
}

.label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--graphite);
}

section {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--ink);
}

section[hidden] {
  display: none;
}

button, .primary, .secondary {
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.primary {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 18px;
  border: 0;
  border-radius: 2px;
  background: var(--ink);
  color: var(--sheet);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.primary:active {
  opacity: 0.85;
}

.primary:disabled {
  opacity: 0.6;
  cursor: progress;
}

.secondary {
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
}

.secondary:active {
  background: var(--sheet);
}

label.secondary {
  display: flex;
  align-items: center;
  justify-content: center;
}

#pick {
  gap: 12px;
}

/* Phones and tablets: camera first, no paste or drop */
.desktop-only {
  display: none;
}

.drop {
  min-height: 120px;
  border: 1px dashed var(--rule);
  border-radius: 2px;
  align-items: center;
  justify-content: center;
  color: var(--graphite);
  font-size: 13px;
}

.drop.over {
  border-color: var(--ink);
  background: var(--sheet);
  color: var(--ink);
}

/* Computers with a mouse: choose, paste or drop; the camera button goes away */
@media (hover: hover) and (pointer: fine) {
  .mobile-only {
    display: none;
  }

  .desktop-only {
    display: flex;
  }

  label.choose {
    min-height: 52px;
    border: 0;
    background: var(--ink);
    color: var(--sheet);
    font-weight: 500;
    letter-spacing: 0.02em;
  }

  label.choose:active {
    background: var(--ink);
    opacity: 0.85;
  }

  .desktop-only.secondary {
    justify-content: center;
    align-items: center;
  }
}

.preview {
  margin: 0;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--sheet);
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.topics {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.topics legend {
  padding: 0;
  margin-bottom: 10px;
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.topic {
  min-height: 48px;
  padding: 8px 12px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--sheet);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.3;
  text-align: left;
}

.topic[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--sheet);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field input {
  min-height: 44px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

.field input:focus {
  outline: none;
  border-bottom-color: var(--vermilion);
}

button:focus-visible, .primary:focus-visible {
  outline: 2px solid var(--vermilion);
  outline-offset: 2px;
}

.status {
  margin: 0;
  min-height: 1.7em;
  color: var(--graphite);
  font-size: 13px;
}

.status.error {
  color: var(--vermilion-text);
}

.dropzone {
  position: fixed;
  inset: 12px;
  border: 1px dashed var(--ink);
  border-radius: 2px;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 300;
  z-index: 10;
}

.dropzone[hidden] {
  display: none;
}

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