/* Magpie. Cool slate and teal: the notebook, not the darkroom. */

:root {
  --paper: #eef2f0;
  --paper-2: #e2e9e6;
  --card: #f8faf9;
  --ink: #17211f;
  --ink-soft: #51625d;
  --accent: #17697a;
  --accent-ink: #f2fbfd;
  --line: #c8d4d0;
  --warn: #a02c1f;
  --warn-bg: #f5ddd7;
  --ok: #24684a;
  --ok-bg: #d9eade;
  --shadow: 0 2px 14px rgba(23, 33, 31, 0.12);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101413;
    --paper-2: #18201e;
    --card: #1a2321;
    --ink: #e2ebe8;
    --ink-soft: #9fb1ac;
    --accent: #57b7c9;
    --accent-ink: #0a1e22;
    --line: #2b3835;
    --warn: #f08575;
    --warn-bg: #43231d;
    --ok: #7fc9a3;
    --ok-bg: #1d3a2c;
    --shadow: 0 2px 14px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  /* Leaves the root size at the browser/OS default so rem below tracks a
     visitor's own text-size preference instead of overriding it. */
  font-size: 100%;
}
html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100%;
}

img { max-width: 100%; }
code { overflow-wrap: anywhere; font-size: 0.8125rem; }

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

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 16px;
  z-index: 40;
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius);
  padding: 12px 22px;
  font-weight: 650;
  min-height: 44px;
  text-decoration: none;
  border: 1px solid transparent;
}
.btn-primary[disabled] { opacity: 0.5; cursor: default; }
.btn-ghost {
  color: var(--accent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 16px;
  min-height: 44px;
  font-weight: 600;
  background: transparent;
}
.btn-danger {
  background: var(--warn);
  color: var(--accent-ink);
  border-radius: var(--radius);
  padding: 12px 22px;
  min-height: 44px;
  font-weight: 650;
}
.btn-danger[disabled] { opacity: 0.4; cursor: default; }
.icon-btn { min-width: 44px; min-height: 44px; border-radius: 12px; font-size: 1.1875rem; color: var(--ink-soft); }
.icon-btn:hover { background: var(--paper-2); color: var(--ink); }

.screen { max-width: 760px; margin: 0 auto; padding: 18px 18px 60px; }
.hero { text-align: center; padding-top: 22px; }
.hero .logo { display: block; margin: 0 auto 6px; }
.hero h1 { margin: 0; font-size: 2.5rem; }
.tagline { margin: 2px 0 14px; font-size: 1.1875rem; font-weight: 600; color: var(--accent); }
.pitch { max-width: 36em; margin: 0 auto 24px; color: var(--ink-soft); text-align: left; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 14px auto;
  max-width: 460px;
  text-align: left;
}
.card h2 { margin: 0 0 10px; font-size: 1.1875rem; }
.form label { display: block; font-weight: 600; margin: 12px 0 4px; }
.form input[type="password"], .form input[type="text"], .form textarea, .danger-body input {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
}
.form textarea { resize: vertical; }
.form .btn-primary { margin-top: 16px; width: 100%; }
.warn-line { color: var(--warn); font-size: 0.875rem; }
.hint-line { color: var(--ink-soft); font-size: 0.875rem; }

.landing { margin-top: 52px; }
.lnd { margin-bottom: 40px; }
.lnd h2 { font-size: 1.5rem; }
.lnd p { color: var(--ink-soft); }
.lnd-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.lnd-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.lnd-card h3 { margin: 0 0 6px; font-size: 1.03rem; }
.lnd-card p { margin: 0; font-size: 0.9rem; }
.honest-list { padding-left: 20px; color: var(--ink-soft); }
.honest-list li { margin-bottom: 10px; }
.apk-row { margin: 14px 0 4px; }
.land-footer { display: flex; gap: 18px; padding: 16px 0 4px; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: 0.875rem; }
.land-footer a { color: var(--accent); }
.about-line { text-align: center; margin-top: 30px; color: var(--ink-soft); font-size: 0.875rem; }
.about-line a { color: var(--accent); }
.locale-line { text-align: center; margin-top: 24px; }
.locale-line select {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  min-height: 44px;
}

.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 4px 0 12px; }
.topbar h1 { margin: 0; font-size: 1.125rem; font-weight: 700; }
.top-space { flex: 1; }
.topbar #btn-lock { margin-left: auto; }
.chain-badge { font-size: 0.8125rem; font-weight: 700; border-radius: 999px; padding: 3px 10px; }
.chain-badge:empty { padding: 0; }
.chain-badge.ok { background: var(--ok-bg); color: var(--ok); }
.chain-badge.bad { background: var(--warn-bg); color: var(--warn); }

/* Badge on its own row so the buttons fit one row down to 360px in Spanish. */
@media (max-width: 560px) {
  #screen-timeline .topbar { column-gap: 6px; row-gap: 4px; }
  #screen-timeline .topbar::after { content: ""; order: 1; flex-basis: 100%; }
  .topbar .chain-badge { order: 2; }
  .topbar .btn-ghost { padding-left: 12px; padding-right: 12px; }
}

/* The chain spine: a dashed line down the left edge of the timeline, with
   one dot per entry, so the app looks like what it claims to be. */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; margin-bottom: 14px; padding-left: 28px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: repeating-linear-gradient(to bottom, var(--accent) 0 6px, transparent 6px 11px);
  opacity: 0.55;
}
.tl-dot {
  position: absolute;
  left: 0;
  top: 16px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--accent);
}
.timeline button {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.timeline button:hover { border-color: var(--accent); }
.tl-title { font-weight: 650; }
.tl-meta { color: var(--ink-soft); font-size: 0.845rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.tl-hash {
  font-size: 0.75rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
  color: var(--accent);
}

@keyframes chain-seal {
  0% { transform: scale(0.92); opacity: 0; }
  55% { transform: scale(1.015); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.tl-seal { animation: chain-seal 0.4s ease; }
.tl-seal .tl-dot { animation: chain-seal 0.4s ease 0.05s both; }

.empty { color: var(--ink-soft); text-align: center; padding: 40px 16px; }
.empty-art { color: var(--line); margin-bottom: 8px; }
.empty-title { font-weight: 650; color: var(--ink); margin: 0 0 6px; }
.empty-sub { margin: 0 auto; max-width: 30em; font-size: 0.9rem; }

/* Never display:none this: it is a role=status live region, and toggling
   an empty live region to visible right when it gets its first text can
   mean the announcement is missed. Staying in the flow costs nothing; it
   has no border or background, so an empty line is visually inert. */
.anchor-line { text-align: center; margin: 0 0 12px; min-height: 1.55em; }

.search-row { margin: 4px 0 14px; }
.search-row input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
}

.addbar { position: sticky; bottom: 14px; text-align: center; margin-top: 18px; }
.addbar .btn-primary { box-shadow: var(--shadow); min-width: 200px; }

.danger { margin-top: 34px; color: var(--ink-soft); }
.danger summary { cursor: pointer; display: flex; align-items: center; min-height: 44px; font-weight: 600; }
.danger-body { padding: 10px 0; display: grid; gap: 10px; max-width: 420px; }
.danger-body select { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-height: 44px; }
.danger-body label { font-weight: 600; margin: 0; }
.settings-about { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 0.875rem; }
.settings-about a { color: var(--accent); }

.add-form { max-width: 560px; margin: 0 auto; }
.attach-row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.attach-name { color: var(--ink-soft); font-size: 0.875rem; }

.entry-body { max-width: 620px; margin: 0 auto; }
.entry-meta { color: var(--ink-soft); font-size: 0.875rem; }
.entry-note { white-space: pre-wrap; }
.entry-img { border-radius: var(--radius); border: 1px solid var(--line); }
.hash-line { color: var(--ink-soft); font-size: 0.845rem; }

.done-actions { display: flex; gap: 12px; margin: 16px 0; }
.done-actions .btn-primary { min-width: 130px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  padding: 10px 18px;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  z-index: 50;
  max-width: min(92vw, 480px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s;
}
.toast.show { opacity: 1; visibility: visible; }

.restore-block { padding: 4px 0; }
.restore-block summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; padding: 0 20px; }
.restore-block .form { padding: 0 20px 16px; }

@keyframes lock-shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-5px); }
  40%, 60% { transform: translateX(5px); }
}
.shake { animation: lock-shake 0.4s; }

@keyframes unlock-exhale {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
#screen-timeline:not([hidden]) { animation: unlock-exhale 0.35s ease; }

@media (prefers-reduced-motion: reduce) {
  .toast { transition-duration: 0.01ms; }
  .shake, .tl-seal, .tl-seal .tl-dot, #screen-timeline:not([hidden]) { animation: none; }
}

.doc-page main { max-width: 680px; margin: 0 auto; padding: 32px 20px; }
