/*
  app.css

  CSS in 30 seconds: each rule is "selector { property: value; }".
    .card     = every element with class="card"
    #results  = the one element with id="results"
    a b       = a "b" anywhere inside an "a"
  When two rules conflict, the more specific or later one wins.
*/

/*
  Design tokens. Custom properties (--name) act like constants you can
  override, and :root is the <html> element, so these apply everywhere.
  Every color below is var(--something), so dark mode only has to redefine
  the tokens, not every rule.
*/
:root {
  --bg: #f6f5f1;          /* warm paper */
  --surface: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6a64;
  --border: #e2e0d8;
  --accent: #2f5d8a;      /* ink blue */
  --accent-text: #ffffff;
  --mark: #fde9a8;        /* highlighter yellow */
  --mark-active: #f6c945;
  --danger-bg: #fdecea;
  --danger-text: #8a1c12;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 2px 8px rgba(0, 0, 0, .04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark; /* native controls (scrollbars, file inputs) follow the theme */
}

/* Follow the OS dark-mode setting */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161614;
    --surface: #211f1c;
    --text: #ecebe6;
    --muted: #a19f97;
    --border: #36342f;
    --accent: #7fb0e0;
    --accent-text: #0f1a26;
    --mark: #5a4a14;
    --mark-active: #8a6d10;
    --danger-bg: #3b1d19;
    --danger-text: #ffb4a8;
    --shadow: none;
  }
}

/* border-box: width includes padding and border. Makes sizing much less surprising. */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* Centered column. min() picks whichever is smaller: 960px, or the screen width minus a 16px gutter each side. */
.page {
  width: min(960px, 100% - 32px);
  margin: 0 auto;
  padding: 32px 0 64px;
}

.masthead h1 { margin: 0 0 4px; font-size: 1.75rem; letter-spacing: -.01em; }
.lede { margin: 0 0 24px; color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

h2 { margin: 0; font-size: 1.35rem; }
h3 { margin: 20px 0 10px; font-size: .95rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.card > h3:first-child { margin-top: 0; }
.hint { text-transform: none; letter-spacing: 0; font-weight: normal; font-size: .85rem; }

/* ---------- Form ---------- */

.field { display: grid; gap: 6px; margin-bottom: 16px; max-width: 320px; }
.field label { font-weight: 600; font-size: .9rem; }
input[type="password"] {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

/*
  The drop zone. It's a <label>, so it's inline by default; display:grid turns
  it into a block and stacks its children. place-items centers them.
*/
.drop-zone {
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 36px 16px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
/* app.js adds the .dragging class while a file is dragged over the box */
.drop-zone:hover, .drop-zone.dragging {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}
/*
  Hide the real file input but keep it usable by keyboard and screen readers.
  (display:none would remove it from tab order.)
*/
.drop-zone input {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
}
/* :focus-within = "some child has focus". Shows a ring when you tab to the hidden input. */
.drop-zone:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.drop-title { font-weight: 600; font-size: 1.05rem; }
.drop-sub { color: var(--muted); font-size: .9rem; }

/*
  Thumbnail grid. auto-fill with minmax(): fit as many 110px+ columns as the
  width allows, then stretch them to fill the row. Responsive without media queries.
*/
.file-list {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
}
.file-list:empty { display: none; }
.file-list li {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
  font-size: .75rem;
}
.file-list img, .file-list .pdf-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;      /* portrait, like a sheet of paper */
  object-fit: cover;        /* crop to fill instead of squashing */
}
.file-list .pdf-thumb { display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.file-list .name { padding: 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-list .page-no {
  position: absolute; top: 4px; left: 4px;
  background: var(--accent); color: var(--accent-text);
  border-radius: 999px; padding: 0 7px; font-weight: 700;
}
.file-list .remove {
  position: absolute; top: 4px; right: 4px;
  width: 24px; height: 24px;
  border: none; border-radius: 50%;
  background: rgba(0, 0, 0, .6); color: #fff;
  cursor: pointer; line-height: 1;
}

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; }
.status { color: var(--muted); font-size: .9rem; }

.btn {
  font: inherit;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { padding: 5px 10px; font-size: .85rem; }

.error { background: var(--danger-bg); color: var(--danger-text); border-color: transparent; }

/* ---------- Results ---------- */

.result-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }
.result-tools { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }
.meta { margin: 4px 0 0; color: var(--muted); font-size: .85rem; }
.summary { margin: 14px 0 0; font-size: 1.02rem; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font: inherit;
  font-size: .82rem;
  padding: 3px 10px;
  border-radius: 999px;          /* pill shape */
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.tag.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.tag.static { cursor: default; font-size: .75rem; padding: 1px 8px; }

/*
  Two columns on wide screens. The media query applies these rules only when
  the viewport is at least 760px wide. Phones get a single column.
*/
.columns { display: grid; gap: 16px; }
@media (min-width: 760px) {
  .columns { grid-template-columns: 1fr 1.2fr; align-items: start; }
  /* sticky: the transcript stays in view while you scroll the key ideas */
  .columns > .card:last-child { position: sticky; top: 16px; }
}

.ideas { margin: 0; padding-left: 1.3em; display: grid; gap: 12px; }
.ideas li { cursor: pointer; padding: 6px 8px; border-radius: 8px; margin-left: -8px; }
.ideas li:hover { background: var(--bg); }
.ideas li.active { background: color-mix(in srgb, var(--mark) 60%, transparent); }
.ideas li.filtered-out { display: none; }
.ideas .quote { display: block; color: var(--muted); font-style: italic; font-size: .88rem; margin: 2px 0 6px; }
.ideas .tags { gap: 4px; }

.action-items { margin: 0; padding-left: 1.2em; }
.action-items .who { color: var(--muted); font-size: .88rem; }

/*
  pre-wrap keeps the model's line breaks and indentation (handwritten notes
  are all about layout) but still wraps long lines. max-height plus overflow
  gives the transcript its own scrollbar.
*/
.transcript {
  white-space: pre-wrap;
  font-family: ui-serif, Georgia, "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.6;
  max-height: 70vh;
  overflow-y: auto;
}
.transcript mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.transcript mark.active { background: var(--mark-active); outline: 2px solid var(--mark-active); }
/* .transcript.dim (no space) = one element with both classes; app.js adds "dim" while something is selected */
.transcript.dim mark:not(.active) { background: transparent; }

/* Spinner: a circle with one colored side, rotated forever */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
