/* =========================================================================
   style.css — Newspaper archive search UI
   No external dependencies — works fully offline.
   ========================================================================= */

/* ---- Reset & base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #f5f5f0;
  --surface:    #ffffff;
  --border:     #ddd;
  --primary:    #1a1a2e;
  --accent:     #c0392b;
  --accent-lt:  #f9eaea;
  --text:       #222;
  --muted:      #666;
  --mark-bg:    #ffe066;
  --mark-fg:    #222;
  --radius:     6px;
  --shadow:     0 1px 4px rgba(0,0,0,.10);
  --font:       system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
}

html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ---- Site header ---- */
.site-header {
  background: var(--primary);
  color: #fff;
  padding: 0 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.header-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 52px;
}
.site-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: .03em;
  white-space: nowrap;
}
.logout-link {
  margin-left: auto;
  font-size: .8rem;
  color: rgba(255,255,255,.55);
  text-decoration: none;
  padding: .25rem .5rem;
  border-radius: var(--radius);
  transition: color .15s, background .15s;
  white-space: nowrap;
}
.logout-link:hover { color: #fff; background: rgba(255,255,255,.1); }

/* ---- Tab navigation ---- */
.tab-nav { display: flex; gap: 0; }
.tab-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.65);
  cursor: pointer;
  font-size: .9rem;
  padding: .35rem .9rem;
  border-bottom: 3px solid transparent;
  transition: color .15s, border-color .15s;
  height: 52px;
}
.tab-btn:hover  { color: #fff; }
.tab-btn.active { color: #fff; border-bottom-color: var(--accent); }

/* ---- Main content ---- */
main { max-width: 900px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- Search bar ---- */
.search-bar-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}
.search-row {
  display: flex;
  gap: .5rem;
  margin-bottom: .75rem;
}
.search-input {
  flex: 1;
  font-size: 1rem;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color .15s;
}
.search-input:focus { border-color: var(--primary); }

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: flex-end;
}
.filter-label {
  display: flex;
  flex-direction: column;
  font-size: .8rem;
  color: var(--muted);
  gap: .2rem;
}
.date-input, .select-input {
  font-size: .9rem;
  padding: .35rem .5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  outline: none;
}
.date-input:focus, .select-input:focus { border-color: var(--primary); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .45rem .9rem;
  font-size: .9rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s;
  white-space: nowrap;
}
.btn:hover    { opacity: .85; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary  { background: var(--primary); color: #fff; }
.btn-open     { background: var(--accent);  color: #fff; font-size: .85rem; }
.btn-download {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--border);
  font-size: .85rem;
}
.btn-download:hover { background: var(--bg); opacity: 1; }

/* ---- Search status ---- */
.search-status {
  font-size: .875rem;
  color: var(--muted);
  margin-bottom: .75rem;
}

/* ---- Result cards ---- */
.results-container { display: flex; flex-direction: column; gap: .75rem; }

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  box-shadow: var(--shadow);
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: center;
  margin-bottom: .5rem;
}
.card-paper {
  font-size: .78rem;
  color: var(--muted);
  margin-left: auto;
}
.tag {
  display: inline-block;
  font-size: .75rem;
  font-weight: 600;
  padding: .15rem .45rem;
  border-radius: 4px;
  letter-spacing: .02em;
}
.tag-date { background: var(--primary); color: #fff; }
.tag-supp { background: #e8e0f8; color: #5b21b6; }
.tag-page { background: #e0f0e8; color: #15603a; }
.tag-main { background: #e0eaf8; color: #1a4080; }

.card-snippet {
  font-size: .9rem;
  line-height: 1.6;
  margin-bottom: .65rem;
  color: var(--text);
}
mark {
  background: var(--mark-bg);
  color: var(--mark-fg);
  border-radius: 2px;
  padding: 0 .1em;
}
.card-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---- Pagination ---- */
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  justify-content: center;
  margin-top: 1.5rem;
}
.page-btn, .page-current, .page-ellipsis {
  min-width: 2.2rem;
  height: 2.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-size: .875rem;
}
.page-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s;
}
.page-btn:hover { background: var(--bg); }
.page-current {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  border: 1px solid var(--primary);
}
.page-ellipsis { color: var(--muted); border: none; background: transparent; }

/* ---- Archive / browse tab ---- */
.archive-controls {
  display: flex;
  align-items: flex-end;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.year-nav {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.year-nav-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 2rem;
  height: 2rem;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s;
}
.year-nav-btn:hover    { background: var(--bg); }
.year-nav-btn:disabled { opacity: .35; cursor: not-allowed; }

/* Year display button + picker */
.year-picker-wrap {
  position: relative;
}
.year-display {
  font-size: 1.35rem;
  font-weight: 700;
  min-width: 5.5rem;
  text-align: center;
  color: var(--primary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .2rem .6rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  transition: background .12s, border-color .12s;
  user-select: none;
}
.year-display:hover           { background: var(--bg); border-color: var(--primary); }
.year-display--open           { background: var(--bg); border-color: var(--primary); }
.year-caret {
  font-size: .75rem;
  color: var(--muted);
  transition: transform .15s;
}
.year-display--open .year-caret { transform: rotate(180deg); }

.year-picker {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,.14);
  padding: .6rem;
  z-index: 200;
  min-width: 280px;
  max-width: 360px;
  max-height: 320px;
  overflow-y: auto;
}
.year-picker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
}
.year-chip {
  font-size: .78rem;
  font-weight: 600;
  padding: .3rem .1rem;
  border-radius: 4px;
  text-align: center;
  line-height: 1.3;
  border: none;
}
.year-chip[data-year] {           /* indexed — interactive */
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: background .1s, border-color .1s;
}
.year-chip[data-year]:hover {
  background: var(--bg);
  border-color: var(--primary);
}
.year-chip--selected {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}
.year-chip--unindexed {
  color: #bbb;
  background: transparent;
  cursor: default;
  font-weight: 400;
}

.cal-months {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem 1.25rem;
}
@media (max-width: 860px) { .cal-months { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px) { .cal-months { grid-template-columns: repeat(2, 1fr); } }

.cal-month {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .6rem .5rem;
  box-shadow: var(--shadow);
}
.cal-month-name {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: .4rem;
  padding-bottom: .3rem;
  border-bottom: 1px solid var(--border);
}
.cal-days {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.day-chip {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  font-size: .65rem;
  line-height: 1;
  padding: 0;
}
.day-num { font-size: .65rem; line-height: 1; }

.day-chip--empty {
  color: #ccc;
  background: transparent;
  border: none;
  cursor: default;
  user-select: none;
}
.day-chip--has-issue {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  transition: background .1s, border-color .1s, transform .1s;
}
.day-chip--has-issue:hover {
  background: var(--bg);
  border-color: var(--primary);
  transform: scale(1.15);
  z-index: 1;
}
.day-chip--selected {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}
.day-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 1px;
  display: block;
}
.day-chip--selected .day-dot { background: rgba(255,255,255,.7); }

.day-issues-panel {
  margin-top: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}
.day-issues-header {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: .75rem;
}
.day-paper-name {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin: .75rem 0 .4rem;
  padding-bottom: .25rem;
  border-bottom: 1px solid var(--border);
  width: 100%;
}
.day-paper-name:first-of-type { margin-top: 0; }
.day-issue-cards { display: flex; flex-wrap: wrap; gap: .75rem; margin-bottom: .25rem; }
.issue-browse-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ---- Login page ---- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 1rem;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  padding: 2rem 2.25rem;
  width: 100%;
  max-width: 340px;
}
.login-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1.5rem;
  text-align: center;
}
.login-label {
  display: flex;
  flex-direction: column;
  font-size: .85rem;
  color: var(--muted);
  gap: .3rem;
  margin-bottom: 1rem;
}
.login-input {
  font-size: 1rem;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color .15s;
  width: 100%;
}
.login-input:focus { border-color: var(--primary); }
.login-btn {
  width: 100%;
  justify-content: center;
  padding: .6rem;
  font-size: 1rem;
  margin-top: .25rem;
}
.login-error {
  font-size: .85rem;
  color: var(--accent);
  margin-bottom: .75rem;
  text-align: center;
}

/* ---- Archive stats ---- */
.archive-stats {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.stats-section-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin-bottom: .75rem;
}
.stats-global {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-bottom: 1.25rem;
}
.stat-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 90px;
  box-shadow: var(--shadow);
}
.stat-chip--wide { min-width: 180px; }
.stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}
.stat-label {
  font-size: .7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-top: .15rem;
}
.stats-papers {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}
.stats-paper-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  box-shadow: var(--shadow);
  flex: 1;
  min-width: 220px;
}
.stats-paper-name {
  font-size: .85rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: .6rem;
}
.stats-paper-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.stats-paper-grid .stat-chip { min-width: 70px; }
.stats-paper-grid .stat-chip--wide { min-width: 160px; }
.stats-paper-grid .stat-value { font-size: .95rem; }

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .header-inner { gap: 1rem; }
  .site-title   { font-size: 1rem; }
  .search-row   { flex-direction: column; }
  .search-input { font-size: .95rem; }
  .filter-row   { gap: .5rem; }
  .card-paper   { display: none; }
  .day-chip     { width: 20px; height: 20px; }
  .day-num      { font-size: .55rem; }
}
