/* Θέματα DIT – restrained, readable, mobile-first. One accent colour, system fonts. */

:root {
  --bg: #fbfaf7;
  --bg-elevated: #ffffff;
  --ink: #1b1d21;
  --ink-muted: #5c6168;
  --line: #dedbd3;
  --accent: #0f4c81;
  --accent-ink: #ffffff;
  --accent-soft: #e6eef6;
  --chip-bg: #f1efe9;
  --chip-on-bg: #1b1d21;
  --chip-on-ink: #fbfaf7;
  --badge-bg: #e6eef6;
  --badge-ink: #0f4c81;
  --focus: #d97706;
  --radius: 10px;
  --max: 44rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --bg-elevated: #1d2024;
    --ink: #e8e6e1;
    --ink-muted: #a2a7ae;
    --line: #33373d;
    --accent: #7fb2e5;
    --accent-ink: #0d1117;
    --accent-soft: #1f2a37;
    --chip-bg: #24282d;
    --chip-on-bg: #e8e6e1;
    --chip-on-ink: #15171a;
    --badge-bg: #1f2a37;
    --badge-ink: #a9cdf0;
    --focus: #f59e0b;
  }
}

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

[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  line-height: 1.5;
  padding: 0 1rem 3rem;
}

a { color: var(--accent); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.muted { color: var(--ink-muted); }

/* ---------------------------------------------------------------- header --- */
.site-header {
  max-width: var(--max);
  margin: 0 auto;
  padding: 2rem 0 1rem;
}
.site-header.compact { padding: 1.25rem 0 0.5rem; }
.site-title { font-size: 1.9rem; font-weight: 700; }
.site-subtitle { margin: 0.35rem 0 0; color: var(--ink-muted); font-size: 0.95rem; }
.back { font-size: 0.95rem; text-decoration: none; }
.back:hover { text-decoration: underline; }

main { max-width: var(--max); margin: 0 auto; }

/* ---------------------------------------------------------------- search --- */
.search-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0.75rem 0;
  margin: 0 -1rem;
  padding-left: 1rem;
  padding-right: 1rem;
  background: var(--bg);
}
#q {
  width: 100%;
  font: inherit;
  font-size: 1.1rem;
  padding: 0.8rem 1rem;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
}
#q:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
#q::placeholder { color: var(--ink-muted); }

/* --------------------------------------------------------------- filters --- */
.filters { display: flex; flex-direction: column; gap: 0.75rem; margin: 0.5rem 0 1rem; transition: opacity 0.15s; }
.filters.is-dimmed { opacity: 0.45; }
.filter { border: 0; margin: 0; padding: 0; min-width: 0; }
.filter legend { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted); padding: 0; margin-bottom: 0.4rem; }
.filter-hint { text-transform: none; letter-spacing: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  font: inherit;
  font-size: 0.95rem;
  padding: 0.45rem 0.85rem;
  min-height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
}
.chip[aria-pressed="true"] { background: var(--chip-on-bg); color: var(--chip-on-ink); border-color: var(--chip-on-bg); }

.status { margin: 0.25rem 0 0.75rem; color: var(--ink-muted); font-size: 0.95rem; min-height: 1.2em; }
.empty { padding: 1.5rem 0; color: var(--ink-muted); }

/* ------------------------------------------------------------ course list --- */
.semester { margin: 1.5rem 0 0; }
.semester-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--line);
}
.courses { list-style: none; margin: 0; padding: 0; }
.course { border-bottom: 1px solid var(--line); }
.course-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.8rem 0.25rem;
  color: inherit;
  text-decoration: none;
}
.course-link:hover .course-title, .course-link:focus-visible .course-title { color: var(--accent); text-decoration: underline; }
.course-main { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.course-title { font-weight: 600; }
.course-meta { font-size: 0.85rem; color: var(--ink-muted); }
.badge {
  flex: none;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: var(--badge-bg);
  color: var(--badge-ink);
  white-space: nowrap;
}
.badge-empty { background: transparent; color: var(--ink-muted); border: 1px solid var(--line); font-weight: 500; }

/* ----------------------------------------------------------- course page --- */
.course-heading { font-size: 1.7rem; margin: 0.25rem 0 1rem; }
.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 1rem;
  margin: 0 0 1.5rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elevated);
}
.fact dt { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted); }
.fact dd { margin: 0.1rem 0 0; font-weight: 600; }
.fact abbr { text-decoration: none; }
.prereqs, .papers { margin: 0 0 1.75rem; }
.prereqs h2, .papers h2 { font-size: 1.15rem; margin-bottom: 0.5rem; }
.prereqs p { margin: 0; }

/* The reverse view: which courses this one gates. Collapsed until asked for. */
.unlocks { margin-top: 0.7rem; }
.unlocks > summary {
  cursor: pointer;
  display: inline-block;
  font-size: 0.9rem;
  color: var(--accent);
  padding: 0.15rem 0;
}
.unlocks > summary:hover { text-decoration: underline; }
.unlock-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0 0 0 0.9rem;
  border-left: 2px solid var(--line);
}
.unlock-list li { margin: 0 0 0.3rem; }
.unlock-sem { color: var(--ink-muted); font-size: 0.82rem; white-space: nowrap; }
.count { color: var(--ink-muted); font-weight: 500; }

.papers-head { margin: 0.5rem 0 1rem; }
.button-primary {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 0.9rem 1.2rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  touch-action: manipulation;
}
.button-primary:hover { filter: brightness(1.08); }
.button-primary[disabled] { opacity: 0.6; cursor: progress; }
.papers-head .status { margin: 0.5rem 0 0; }

/* Paper cards: a thumbnail is a glance target, so keep two per row even on a phone
   and keep each card short enough that the download button stays in view. */
.paper-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.9rem;
}
.paper { min-width: 0; }
.paper-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  overflow: hidden;
}

.paper-thumb {
  display: block;
  position: relative;
  aspect-ratio: 1 / 1.414;
  background: #fff;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
/* The preview opens a larger copy; the download button below is the way to the PDF. */
a.paper-zoom { cursor: zoom-in; }
.paper-zoom-hint {
  position: absolute;
  left: 50%;
  bottom: 0.5rem;
  transform: translateX(-50%);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(16, 18, 22, 0.78);
  color: #fff;
  opacity: 0;
  transition: opacity 0.12s;
  pointer-events: none;
}
a.paper-zoom:hover .paper-zoom-hint,
a.paper-zoom:focus-visible .paper-zoom-hint { opacity: 1; }
@media (hover: none) {
  .paper-zoom-hint { opacity: 1; }
}
.paper-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  /* Cover from the top: the header identifies the paper at a glance. */
  object-fit: cover;
  object-position: top center;
}
.paper-thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--chip-bg);
}
.paper-thumb-tag {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.2rem 0.45rem;
}

.paper-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.6rem 0.7rem 0.7rem;
  flex: 1;
}
.paper-label { font-weight: 600; font-size: 0.92rem; line-height: 1.3; }
.paper-meta { font-size: 0.8rem; color: var(--ink-muted); }
.paper-download {
  margin-top: auto;
  padding-top: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--accent);
}
.paper-download::after { content: " ↓"; font-weight: 700; }
.paper-download:hover, .paper-download:focus-visible { text-decoration: underline; }

/* ------------------------------------------------------------- zoom overlay --- */
.zoom {
  width: min(96vw, 60rem);
  max-width: none;
  max-height: 94vh;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--ink);
  overflow: hidden;
}
.zoom::backdrop { background: rgba(10, 12, 15, 0.72); }
.zoom-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--line);
}
.zoom-title { font-weight: 600; font-size: 0.95rem; flex: 1; min-width: 0; }
.zoom-download { font-size: 0.85rem; font-weight: 600; white-space: nowrap; text-decoration: none; color: var(--accent); }
.zoom-download::after { content: " ↓"; font-weight: 700; }
.zoom-download:hover { text-decoration: underline; }
.zoom-close {
  flex: none;
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--chip-bg);
  color: var(--ink);
  cursor: pointer;
}
.zoom-body {
  overflow: auto;
  max-height: calc(94vh - 6.5rem);
  background: #fff;
  text-align: center;
}
/* Never scale past the image's own pixels — upscaling only makes it blurry.
   --zoom-natural is set from naturalWidth when the image loads. */
.zoom-body img {
  display: block;
  width: 100%;
  max-width: var(--zoom-natural, 900px);
  height: auto;
  margin: 0 auto;
}
/* Actual size: the image overflows and the container scrolls, for a real close look.
   Only reachable on screens narrower than the image, where it genuinely zooms. */
.zoom-body.can-zoom img { cursor: zoom-in; }
.zoom-body.is-actual img { width: auto; max-width: none; margin: 0; cursor: zoom-out; }
/* Pages 2+ are stacked directly under page 1, so they need a visible seam. The border
   carries it in actual-size mode too, where the margin above is zeroed out. */
.zoom-body .zoom-page-extra { margin-top: 0.9rem; border-top: 2px solid var(--line); }
.zoom-body.is-actual .zoom-page-extra { margin-top: 0; }
.zoom-note {
  margin: 0;
  padding: 0.45rem 0.75rem;
  font-size: 0.78rem;
  color: var(--ink-muted);
  border-top: 1px solid var(--line);
  text-align: center;
}

.empty-state {
  padding: 1.25rem 1rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--ink-muted);
}
.empty-state p { margin: 0; }
.empty-state p + p { margin-top: 0.5rem; }
.empty-title { color: var(--ink); font-weight: 600; }

/* ---------------------------------------------------------------- footer --- */
.site-footer {
  max-width: var(--max);
  margin: 3rem auto 0;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--ink-muted);
}
.site-footer p { margin: 0.35rem 0; }

@media (min-width: 40rem) {
  html { font-size: 18px; }
  body { padding: 0 1.5rem 4rem; }
  .search-bar { margin: 0; padding-left: 0; padding-right: 0; }
  .filters { flex-direction: row; gap: 2rem; }
  .facts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .button-primary { width: auto; }
  .paper-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1.1rem; }
}
