/* style.css — looks for the inbox page and the setup page.
   Plain and calm on purpose: function first, no fancy skin. */

/* ---------- Colours (light by default, dark when the system is dark) ---------- */
:root {
  color-scheme: light dark;
  --bg: #f5f4f0;        /* page background */
  --card: #ffffff;      /* card and sheet background */
  --ink: #1c1d1b;       /* main text */
  --quiet: #5f635e;     /* secondary text */
  --line: #dcdad2;      /* borders */
  --soft: #ecebe5;      /* chips, quoted blocks */
  --accent: #0f6b5f;    /* buttons, links */
  --accent-ink: #ffffff;/* text on accent */
  --danger: #b3261e;
  --shade: rgba(0, 0, 0, 0.45);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131514;
    --card: #1d201e;
    --ink: #ecece6;
    --quiet: #a3a79f;
    --line: #343834;
    --soft: #282c29;
    --accent: #58c9b4;
    --accent-ink: #06211c;
    --danger: #ff8a80;
    --shade: rgba(0, 0, 0, 0.6);
  }
}

/* ---------- Basics ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow-wrap: anywhere;            /* very long words and addresses wrap instead of overflowing */
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p, ul, ol { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: var(--accent); }
img { max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* The page column: full width on a phone, centred and narrower on a computer.
   The env(...) values keep content away from the notch and the home bar. */
.wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right))
           calc(120px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
}
.wrap.plain { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; min-width: 44px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink);
  text-decoration: none; cursor: pointer; touch-action: manipulation;
}
.btn.main { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.quiet { background: transparent; border-color: transparent; color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: default; }

input[type="password"], input[type="search"], input[type="text"], textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card);
  font-size: 16px;                    /* 16px stops the iPhone from zooming in on focus */
}
textarea { display: block; resize: vertical; min-height: 120px; line-height: 1.4; }

.error { color: var(--danger); }
.note { color: var(--quiet); }

/* ---------- Sign-in screen and waiting messages ---------- */
.center {
  min-height: 70vh; display: flex; flex-direction: column; justify-content: center; gap: 14px;
  max-width: 360px; margin: 0 auto;
}
.center h1 { font-size: 1.6rem; }
.center label { font-weight: 600; }

/* ---------- Top of the inbox ---------- */
.top { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.top h1 { font-size: 1.5rem; flex: 1; }

/* The three piles (Inbox / Kept / Done) stay visible while scrolling */
.tabs {
  position: sticky; top: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  padding: 6px 0;
  background: var(--bg);
}
.tab {
  min-height: 48px; padding: 4px 6px;
  border: 1px solid var(--line); border-radius: 10px;
  background: transparent; cursor: pointer; touch-action: manipulation;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.tab .count { color: var(--quiet); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.tab[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); font-weight: 600; }
.tab[aria-pressed="true"] .count { color: inherit; opacity: 0.8; }

/* The five filters stay on one line on an iPhone (they used to wrap onto a second
   line). On a very narrow screen the line scrolls sideways instead of wrapping. */
.kinds { display: flex; gap: 5px; margin: 6px 0 10px; overflow-x: auto; scrollbar-width: none; }
.kinds::-webkit-scrollbar { display: none; }
.kind {
  flex: none; min-height: 44px; padding: 6px 11px;
  border: 1px solid var(--line); border-radius: 22px;
  background: transparent; color: var(--quiet); cursor: pointer; touch-action: manipulation;
}
.kind[aria-pressed="true"] { background: var(--soft); border-color: var(--quiet); color: var(--ink); font-weight: 600; }

.search { margin-bottom: 12px; }

/* A message above the list when something went wrong, with a Retry button */
.notice {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 12px 14px; margin-bottom: 12px;
  border: 1px solid var(--danger); border-radius: 12px; background: var(--card);
}
.notice p { flex: 1 1 200px; }

/* ---------- The list ---------- */
.day-title {
  font-size: 0.85rem; font-weight: 600; color: var(--quiet);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin: 18px 2px 8px;
}
.empty { text-align: center; color: var(--quiet); padding: 48px 12px; display: grid; gap: 14px; justify-items: center; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; margin-bottom: 10px;
  display: grid; gap: 10px;
  min-width: 0;
}
.card.sending { opacity: 0.7; }

/* The person's own words: the most visible thing on the card */
.words { font-size: 1.08rem; line-height: 1.4; white-space: pre-wrap; }
.words.clamped { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 8; line-clamp: 8; overflow: hidden; }
.linkish { background: none; border: 0; padding: 0; min-height: 44px; color: var(--accent); cursor: pointer; text-align: left; justify-self: start; }

/* Someone else's words (a link and its excerpt): set apart in a quoted block */
.link {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--soft); border-left: 3px solid var(--line); border-radius: 8px;
  padding: 10px; min-width: 0;
}
.link-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.link-title { font-weight: 600; text-decoration: none; min-height: 44px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
a.link-title:hover { text-decoration: underline; }
.link-site { font-size: 0.85rem; color: var(--quiet); }
.excerpt {
  font-size: 0.92rem; color: var(--quiet); margin-top: 2px;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden;
}
.thumb { width: 72px; height: 72px; flex: none; object-fit: cover; border-radius: 6px; background: var(--line); }

/* A saved picture: tap to see it full size */
.shot { display: block; padding: 0; border: 0; background: none; cursor: zoom-in; justify-self: start; border-radius: 10px; overflow: hidden; }
.shot img { display: block; max-height: 320px; width: auto; max-width: 100%; border-radius: 10px; background: var(--soft); min-height: 44px; min-width: 44px; }

.summary { font-size: 0.92rem; color: var(--quiet); }
.extracts { font-size: 0.95rem; display: grid; gap: 2px; }
.extracts .what { color: var(--quiet); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 0.8rem; padding: 2px 9px; border-radius: 12px; background: var(--soft); color: var(--quiet); }
.chip.maybe { border: 1px dashed var(--quiet); background: transparent; }
.meta { font-size: 0.82rem; color: var(--quiet); }
.reading { font-style: italic; }
.reading::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.2; } }

.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions .dots { margin-left: auto; font-weight: 700; letter-spacing: 0.1em; }

.more-row { display: flex; justify-content: center; margin-top: 16px; }

/* ---------- The big + button, in the thumb zone ---------- */
/* It sits in a solid bar stuck to the bottom of the screen. A button floating over
   the list used to cover "Done" and "Back to Inbox" on the card underneath;
   with a bar, cards simply scroll out of sight behind a clean edge. */
.add-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  padding: 8px 0 calc(10px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--line);
}
.fab {
  width: 60px; height: 60px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--accent-ink);
  font-size: 2.2rem; line-height: 1; font-weight: 300;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  cursor: pointer; touch-action: manipulation;
}

/* ---------- Short messages at the bottom ("Saved ✓", "Undo") ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(100px + env(safe-area-inset-bottom));
  width: max-content; max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 12px;
  padding: 4px 6px 4px 16px; min-height: 52px;
  background: var(--ink); color: var(--bg); border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3); z-index: 20;
}
.toast:empty { display: none; }
.toast span { padding-right: 8px; }
.toast button { min-height: 44px; padding: 4px 12px; border: 1px solid currentColor; border-radius: 8px; background: transparent; color: inherit; font-weight: 600; cursor: pointer; }

/* The full-screen "Saved ✓" used by quick capture */
.saved-big {
  position: fixed; inset: 0; z-index: 30; padding: 24px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: var(--bg); text-align: center;
}
.saved-big .big { font-size: 2.2rem; font-weight: 700; color: var(--accent); }
.saved-big .what { color: var(--quiet); max-width: 420px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }

/* ---------- Sheets (panels that slide up from the bottom) ---------- */
dialog.sheet {
  position: fixed; inset: auto 0 var(--kb, 0px) 0;   /* --kb = height of the iPhone keyboard, set by app.js */
  margin: 0 auto; padding: 0; border: 0;
  width: 100%; max-width: 680px;
  max-height: calc(100vh - var(--kb, 0px) - 12px);
  max-height: calc(100dvh - var(--kb, 0px) - 12px);
  overflow: auto;
  background: var(--card); color: var(--ink);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.25);
}
dialog.sheet[open] { animation: rise 0.18s ease-out; }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
dialog::backdrop { background: var(--shade); }
.sheet-body {
  display: grid; gap: 12px;
  padding: 16px calc(16px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
}
.sheet-body h2 { font-size: 1.1rem; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row .push { margin-left: auto; }
.menu-list { display: grid; gap: 8px; }
.menu-list .btn { justify-content: flex-start; }
.menu-list .btn.danger { margin-top: 10px; }        /* Delete stands apart from the everyday choices */
/* Which item a menu is about: one line, cut with "…" when long */
.one-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* What is attached in the add sheet: a link and/or a picture */
.attached {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  background: var(--soft); border-radius: 10px; padding: 6px 6px 6px 12px;
}
.attached .txt { flex: 1; min-width: 0; font-size: 0.9rem; display: grid; }
.attached .txt span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attached .txt .sub { color: var(--quiet); }
.attached img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; }

/* The picture seen full size */
dialog.viewer {
  width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; background: #000;
}
dialog.viewer[open] { display: flex; align-items: center; justify-content: center; }
dialog.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
dialog.viewer .btn { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: calc(12px + env(safe-area-inset-right)); }

/* ---------- Setup page ---------- */
.setup section { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; display: grid; gap: 10px; }
.setup h2 { font-size: 1.1rem; }
.setup ol { padding-left: 1.3em; display: grid; gap: 6px; }
.value { display: grid; gap: 6px; }
.value .label { font-weight: 600; }
.value code {
  display: block; padding: 10px 12px; border-radius: 8px; background: var(--soft);
  font: 0.9rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all;
}
.shortcut { display: grid; gap: 4px; padding: 10px 0; border-top: 1px solid var(--line); }
.setup h3 { font-size: 1rem; margin-top: 6px; }
.bookmarklet { cursor: grab; font-weight: 700; border-style: dashed; border-color: var(--accent); color: var(--accent); }

/* ---------- People who asked their device for less motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
