/* ============================================================================
   PIN DIARY: reset, typography, and the primitives both pages share.
   ========================================================================== */

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior-y: none;
}

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--step-0);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

/* The grain. Fixed, never animated, barely there, it just stops the surfaces
   reading as flat #hex and makes the paper feel like paper. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
  background-image: var(--grain);
  opacity: var(--grain-opacity);
  mix-blend-mode: multiply;
}
[data-theme="dark"] body::after { mix-blend-mode: screen; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -0.01em;
  margin: 0;
}
h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }

p { margin: 0 0 0.85em; }
p:last-child { margin-bottom: 0; }

a { color: inherit; }

img { display: block; max-width: 100%; }

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  color: inherit;
}

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent-lift);
  outline-offset: 2px;
  border-radius: 6px;
}

::selection { background: var(--accent-wash); }

/* ---- shared type utilities ------------------------------------------------ */

.serif { font-family: var(--font-display); }

/* Small-caps section label. The recurring "chapter heading" of the diary. */
.eyebrow {
  font-family: var(--font-ui);
  font-size: var(--step--2);
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.meta {
  font-size: var(--step--1);
  color: var(--ink-soft);
}

.numeral { font-variant-numeric: tabular-nums; }

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

/* A stitched rule: the divider motif, borrowed from the icon's journey line. */
.stitch {
  height: 1px;
  border: 0;
  margin: 20px 0;
  background-image: linear-gradient(to right, var(--rule-heavy) 0 6px, transparent 6px 100%);
  background-size: 16px 1px;
  background-repeat: repeat-x;
}

/* ---- buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: var(--r-pill);
  background: var(--paper-raised);
  color: var(--ink);
  border: 1px solid var(--rule-heavy);
  font-size: var(--step-0);
  font-weight: 550;
  transition: transform var(--dur-1) var(--ease-out), background var(--dur-1) linear;
}
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: 0.45; cursor: default; }
.btn[disabled]:active { transform: none; }

.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  box-shadow: var(--shadow-1);
}
.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn--ghost:hover { color: var(--ink); }
.btn--block { width: 100%; }
.btn--sm { min-height: 34px; padding: 0 13px; font-size: var(--step--1); }

/* Round icon button. Always at least a 44px tap target even when it looks 36. */
.iconbtn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: var(--r-pill);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow-1);
  color: var(--ink);
  transition: transform var(--dur-1) var(--ease-out);
}
.iconbtn::after {
  content: "";
  position: absolute;
  inset: -4px;                 /* pads the hit area to 46px without growing the pill */
}
.iconbtn:active { transform: scale(0.92); }
.iconbtn--plain { background: transparent; border-color: transparent; box-shadow: none; }
.iconbtn svg { width: 20px; height: 20px; display: block; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 13px;
  border-radius: var(--r-pill);
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow-1);
  font-size: var(--step--1);
  font-weight: 550;
  color: var(--ink);
  white-space: nowrap;
}
.chip svg { width: 16px; height: 16px; flex: none; } /* conductor fix S066: icon() emits unclassed svg; without this the otd chip renders at replaced-element default size */
svg[aria-hidden="true"]:not([class]) { width: 20px; height: 20px; flex: none; } /* conductor fix S066: generic cap for every bare icon() svg — kills the whole oversized-icon class (search-card heart was the second instance) */
.chip--accent { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.chip--quiet { background: var(--paper-sunk); box-shadow: none; color: var(--ink-soft); }

/* ---- fields --------------------------------------------------------------- */

.field { display: block; margin-bottom: 16px; }
.field > .label {
  display: block;
  margin-bottom: 7px;
}
.input {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 11px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--rule-heavy);
  background: var(--paper-raised);
  color: var(--ink);
  font-size: 1rem;             /* 16px min, anything smaller zooms iOS Safari */
  transition: border-color var(--dur-1) linear, box-shadow var(--dur-1) linear;
}
.input:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
.input::placeholder { color: var(--ink-faint); }

/* ---- honest states --------------------------------------------------------
   Every view can be empty, loading, or broken. Each of those is a designed
   state here, never a blank screen and never a spinner with no end. */

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 46px 26px;
  color: var(--ink-soft);
}
.mascot {
  display: block;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.state--mascot { gap: 8px; }
.state--compact { padding: 22px 18px; }
.state__mascot {
  width: clamp(80px, 24vw, 92px);
  height: auto;
  margin-bottom: 2px;
  filter: drop-shadow(0 7px 10px rgba(76, 46, 38, 0.12));
}
.state--compact .state__mascot { width: 80px; }
.state__mark {
  width: 46px; height: 46px;
  color: var(--ink-faint);
  opacity: 0.8;
}
.state__title {
  font-family: var(--font-display);
  font-size: var(--step-2);
  color: var(--ink);
}
.state__body { font-size: var(--step-0); max-width: 30ch; }
.state__mascot-line {
  max-width: 28ch;
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-size: var(--step-0);
  line-height: 1.4;
}
.state .btn { margin-top: 8px; }

/* Skeletons: shaped like the thing that is coming, so the layout never jumps. */
.skeleton {
  background: linear-gradient(90deg, var(--paper-sunk) 0%,
              color-mix(in srgb, var(--paper-sunk) 60%, var(--paper-raised)) 50%,
              var(--paper-sunk) 100%);
  background-size: 300% 100%;
  animation: shimmer 1.5s linear infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer {
  from { background-position: 100% 0; }
  to   { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
