/* ==========================================================================
   tfr.gr — κοινό stylesheet για όλες τις σελίδες
   Τύποι σελίδων (αναγνωρίζονται από τη δομή, χωρίς αλλαγές στα templates):
     αρχική     → body έχει section#about
     λίστες     → body έχει section.archive          (/blog/, /projects/)
     ανάγνωση   → body έχει <article> ως άμεσο παιδί  (άρθρα, βιβλίο, κεφάλαια)
     κεφάλαιο   → ανάγνωση + .kicker                 (serif, drop cap)
   ========================================================================== */

/* ───────── tokens ───────── */
:root {
  --bg: #f7f5f0;
  --surface: #efece5;
  --text: #1a1a1a;
  --body: #34322e;
  --muted: #5e5b55;
  --faint: #8f8b83;
  --border: #dedad1;
  --border-hover: #1a1a1a;
  --accent: #8c2f42;                    /* Velvet */
  --accent-soft: rgba(140, 47, 66, .09);
  --code-bg: rgba(0, 0, 0, .055);
  --mono: "SF Mono", ui-monospace, "Cascadia Mono", "JetBrains Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Noto Sans", sans-serif;
  /* serif με ελληνικά γλυφά σε όλα τα λειτουργικά */
  --serif: "Palatino Linotype", Palatino, "Noto Serif", "Source Serif 4", Georgia, serif;
  --measure: 40rem;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e0e0f;
  --surface: #161617;
  --text: #e9e7e2;
  --body: #c9c6bf;
  --muted: #a19e97;
  --faint: #6b6862;
  --border: #262626;
  --border-hover: #e9e7e2;
  --accent: #d98e9a;
  --accent-soft: rgba(217, 142, 154, .12);
  --code-bg: rgba(255, 255, 255, .06);
  color-scheme: dark;
}

/* ───────── base ───────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(4.5rem + env(safe-area-inset-top, 0px));
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  max-width: var(--measure);
  margin: 0 auto;
  padding: calc(3.5rem + env(safe-area-inset-top, 0px)) 1.5rem calc(4rem + env(safe-area-inset-bottom, 0px));
  transition: background-color .35s var(--ease), color .35s var(--ease);
}
:root[data-theme="dark"] body {
  background: radial-gradient(60rem 30rem at 15% -10%, rgba(217, 142, 154, .04), transparent 60%), var(--bg);
  background-attachment: fixed;
}
::selection { background: var(--accent); color: var(--bg); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

a {
  color: var(--text);
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  border-bottom: 1px solid var(--border);
  transition: background-size .35s var(--ease), color .2s, border-color .2s;
}
a:hover { background-size: 100% 1px; border-bottom-color: transparent; }

/* ───────── theme toggle ───────── */
.theme-toggle {
  position: fixed;
  top: calc(1rem + env(safe-area-inset-top, 0px)); right: 1rem;
  z-index: 20;
  display: grid; place-items: center;
  width: 2.1rem; height: 2.1rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: 999px;
  color: var(--muted); cursor: pointer;
  transition: color .2s, border-color .2s, transform .5s var(--ease);
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); transform: rotate(25deg); }
.theme-toggle svg { width: 15px; height: 15px; stroke: currentColor; stroke-width: 1.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ───────── logo (inline SVG — βλ. partials/logo.html) ───────── */
.site-logo { margin-bottom: 1.75rem; line-height: 0; color: var(--text); }
.site-logo a { border: 0; background: none; display: inline-block; }
.site-logo svg { width: 4.25rem; height: 4.25rem; overflow: visible; }
.site-logo .planet, .site-logo .orbit-front { fill: none; stroke: currentColor; stroke-width: 4; }
.site-logo .orbit-back { fill: none; stroke: currentColor; stroke-width: 3; opacity: .22; stroke-dasharray: 2 9; }
.site-logo .moon { fill: var(--accent); }
/* αν δεν έχει αντικατασταθεί ακόμα το παλιό logo με <img> */
.site-logo img { width: 4.25rem; height: auto; }
.site-logo .logo-dark { display: none; }
[data-theme="dark"] .site-logo .logo-dark { display: inline-block; }
[data-theme="dark"] .site-logo .logo-light { display: none; }

/* ───────── header αρχικής / λιστών ───────── */
body > h1 {
  font-size: clamp(1.9rem, 1.5rem + 1.6vw, 2.5rem);
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.1;
}
body > h1 a { border: 0; background: none; }
.sub {
  color: var(--muted);
  font-family: var(--mono);
  font-size: .78rem;
  line-height: 1.8;
  margin-top: .7rem;
  max-width: 34rem;
}
.sub .alias { white-space: nowrap; }
.sub .alias:not(:last-child)::after { content: "·"; color: var(--faint); margin: 0 .2em 0 .6em; }

/* ───────── navigation ───────── */
nav.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1.1rem;
  margin: 1.75rem -1.5rem 2.5rem;
  padding: calc(.8rem + env(safe-area-inset-top, 0px)) 4rem .8rem 1.5rem;
  font-family: var(--mono); font-size: .8rem;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
nav a { color: var(--muted); border-bottom-color: transparent; }
nav a:hover, nav a.active, nav a.cur { color: var(--text); }
nav.top .langs { margin-left: auto; }
nav.side { display: none; }

.langs { display: inline-flex; gap: .55rem; font-family: var(--mono); font-size: .76rem; }
.langs a { color: var(--faint); border-bottom-color: transparent; }
.langs a:hover { color: var(--text); }
.langs .cur { color: var(--accent); }

/* ───────── sections ───────── */
section { margin-bottom: 3.5rem; }
section > h2 {
  display: flex; align-items: center; gap: .9rem;
  font-family: var(--mono); font-size: .78rem; font-weight: 400;
  letter-spacing: .04em; color: var(--faint);
  margin-bottom: 1.25rem;
}
section > h2::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.hash { color: var(--accent); opacity: .85; }

ul { list-style: none; }
li { font-size: .95rem; }
.desc { color: var(--muted); font-size: .95rem; }

#about .desc { font-size: 1rem; line-height: 1.8; max-width: 36rem; }
#about .desc .line { display: block; }
#about .desc .line:first-child {
  color: var(--text); font-size: 1.12rem; font-weight: 500;
  letter-spacing: -0.01em; margin-bottom: .6rem;
}

/* χρονιά στις λίστες */
.year {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .08em;
  color: var(--accent); margin: 2rem 0 .6rem;
}
.archive > h2 + .year { margin-top: 0; }

/* blog λίστα */
.posts li {
  display: grid; grid-template-columns: 1fr auto; column-gap: 1.5rem;
  align-items: baseline;
  padding: .85rem 0; border-top: 1px solid var(--border);
}
.posts li:first-child { border-top: 0; padding-top: 0; }
.posts li > a { font-weight: 500; justify-self: start; }
.posts .date {
  font-family: var(--mono); font-size: .72rem; color: var(--faint);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
.posts li .desc { grid-column: 1 / -1; display: block; font-size: .87rem; margin-top: .2rem; max-width: 34rem; }
/* στη σελίδα /blog/ οι μεγάλες περιγραφές κόβονται σε 3 γραμμές */
.archive .posts li .desc {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

/* projects λίστα */
.projects { display: grid; gap: .35rem; }
.projects li {
  position: relative;
  padding: .9rem 1rem .95rem; margin: 0 -1rem;
  border-radius: 10px;
  transition: background-color .25s var(--ease);
}
.projects li::before {
  content: ""; position: absolute; left: 0; top: .9rem; bottom: .9rem;
  width: 2px; border-radius: 2px; background: var(--accent);
  transform: scaleY(0); transform-origin: top;
  transition: transform .35s var(--ease);
}
.projects li:hover { background: var(--surface); }
.projects li:hover::before { transform: scaleY(1); }
.projects li > a { font-weight: 550; font-size: 1rem; border-bottom: 0; }
.projects li > a::after { content: ""; position: absolute; inset: 0; border-radius: 10px; }
.projects li > a[target="_blank"] { display: inline-flex; flex-direction: row-reverse; align-items: baseline; gap: .4em; }
.projects li > a[target="_blank"]::before {
  content: "↗"; font-family: var(--mono); font-size: .78em; color: var(--faint);
  transition: color .2s, transform .3s var(--ease);
}
.projects li:hover > a[target="_blank"]::before { color: var(--accent); transform: translate(.15em, -.15em); }
.projects .desc { display: block; font-size: .87rem; margin-top: .25rem; max-width: 34rem; white-space: pre-line; }
.badge {
  display: inline-block;
  font-family: var(--mono); font-size: .68rem; letter-spacing: .02em;
  color: var(--accent); background: var(--accent-soft);
  padding: .1rem .5rem; border-radius: 999px;
  margin: .35rem 0 .1rem;
}
.projects .badge + .desc { margin-top: .3rem; }

.more { margin-top: 1.1rem; font-family: var(--mono); font-size: .8rem; }
.more a { color: var(--muted); border-bottom-color: transparent; }
.more a:hover { color: var(--accent); }

/* ==========================================================================
   Σελίδες ανάγνωσης (άρθρα, βιβλίο, κεφάλαια)
   ========================================================================== */
body:has(> article) { max-width: 42rem; padding-top: calc(2.25rem + env(safe-area-inset-top, 0px)); }

/* πάνω μπάρα: ← πίσω αριστερά, γλώσσες δεξιά */
a.top {
  font-family: var(--mono); font-size: .78rem; color: var(--muted);
  border-bottom-color: transparent;
  display: inline-block; margin-top: .35rem;
}
a.top:hover { color: var(--accent); }
body > nav.langs {
  float: right; margin: .35rem 2.9rem 0 0;
  display: flex; gap: .55rem;
}

.kicker {
  clear: both;
  font-family: var(--mono); font-size: .74rem; letter-spacing: .03em;
  margin: 3rem 0 .5rem;
}
.kicker a { color: var(--accent); border-bottom-color: transparent; }
body:has(> article) > h1 {
  clear: both;
  font-size: clamp(1.7rem, 1.3rem + 1.6vw, 2.35rem);
  font-weight: 650; letter-spacing: -0.022em; line-height: 1.18;
  margin: 3rem 0 .7rem;
  text-wrap: balance;
}
.kicker + h1 { margin-top: 0 !important; }
body > .date {
  display: block;
  font-family: var(--mono); font-size: .74rem; color: var(--faint);
  padding-bottom: 1.6rem; margin-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}
.reading-time::before { content: "·"; margin: 0 .55em; }

article {
  font-size: 1.04rem; line-height: 1.8; color: var(--body);
  hyphens: auto; -webkit-hyphens: auto;
}
article > * + * { margin-top: 1.15rem; }
article p { margin-bottom: 0; }
article h2 {
  font-family: var(--sans); font-size: 1.2rem; font-weight: 600; letter-spacing: -0.01em;
  color: var(--text); margin-top: 2.6rem !important; line-height: 1.35;
}
article h2::before { content: "## "; font-family: var(--mono); font-size: .8em; font-weight: 400; color: var(--accent); }
article h3 { font-size: 1.02rem; font-weight: 600; color: var(--text); margin-top: 1.9rem !important; }
article h2 + *, article h3 + * { margin-top: .6rem; }
article h2[id], article h3[id] { scroll-margin-top: 1.5rem; }
article strong { color: var(--text); font-weight: 600; }
article em { color: var(--text); }
article a { color: var(--text); border-bottom: 1px solid var(--accent); }
article a:hover { color: var(--accent); }
article ul, article ol { padding-left: 1.3rem; }
article ul { list-style: none; }
article ul > li { position: relative; }
article ul > li::before { content: "–"; position: absolute; left: -1.1rem; color: var(--accent); }
article ol > li::marker { font-family: var(--mono); font-size: .85em; color: var(--accent); }
article li { font-size: inherit; margin-bottom: .4rem; padding-left: .15rem; }
article blockquote {
  padding: .2rem 0 .2rem 1.2rem; border-left: 2px solid var(--accent);
  color: var(--muted); font-style: italic;
}
article img, article video { max-width: 100%; height: auto; border-radius: 8px; display: block; }
article figure figcaption { font-size: .82rem; color: var(--faint); margin-top: .5rem; text-align: center; }
article hr {
  border: 0; height: auto; margin: 2.75rem 0 !important; text-align: center;
  color: var(--faint); overflow: visible;
}
article hr::after { content: "⁂"; font-size: 1.1rem; letter-spacing: .3em; }
article code {
  font-family: var(--mono); font-size: .84em;
  background: var(--code-bg); padding: .12em .35em; border-radius: 4px;
  color: var(--text); hyphens: none;
}
article pre {
  position: relative;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 1rem 1.1rem; overflow-x: auto;
  font-size: .95rem; line-height: 1.6; hyphens: none;
}
article pre code { background: none; padding: 0; font-size: .86em; }
.copy-btn {
  position: absolute; top: .5rem; right: .5rem;
  font-family: var(--mono); font-size: .68rem;
  color: var(--faint); background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px;
  padding: .15rem .5rem; cursor: pointer; opacity: 0;
  transition: opacity .2s, color .2s, border-color .2s;
}
article pre:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }
article table { width: 100%; border-collapse: collapse; font-size: .9rem; }
article th, article td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); }
article th { font-family: var(--mono); font-size: .75rem; font-weight: 400; color: var(--faint); }
article .embed { position: relative; width: 100%; aspect-ratio: 16 / 9; }
article .embed iframe { width: 100%; height: 100%; border: 1px solid var(--border); border-radius: 10px; display: block; }
article .sources { margin-top: 3rem !important; padding-top: 1.4rem; border-top: 1px solid var(--border); }
article .sources h2 { margin-top: 0 !important; font-size: .95rem; }
article .sources ul { padding: 0; }
article .sources li { font-size: .85rem; line-height: 1.55; color: var(--muted); padding-left: 0; }
article .sources li::before { display: none; }
article .sources a { color: var(--muted); border-bottom-color: var(--border); }

/* ───────── βιβλίο: σελίδα περιεχομένων ───────── */
article .book-lead { font-family: var(--serif); font-size: 1.15rem; line-height: 1.75; color: var(--text); }
.book-start { font-family: var(--mono); font-size: .82rem; }
.book-start a {
  display: inline-block; border: 1px solid var(--accent); border-radius: 999px;
  padding: .45rem 1rem; color: var(--accent); background: none;
  transition: background-color .2s, color .2s;
}
.book-start a:hover { background: var(--accent); color: var(--bg); }
ol.chapters { list-style: none; padding: 0; margin-top: 2.2rem !important; counter-reset: none; }
ol.chapters li {
  position: relative; padding: 1rem 1rem 1rem 3.4rem; margin: 0 -1rem;
  border-top: 1px solid var(--border); border-radius: 0;
  line-height: 1.45; transition: background-color .25s var(--ease);
}
ol.chapters li:last-child { border-bottom: 1px solid var(--border); }
ol.chapters li::marker { content: none; }
ol.chapters li:hover { background: var(--surface); }
ol.chapters li a { color: var(--text); font-weight: 550; border: 0; background: none; }
ol.chapters li a::after { content: ""; position: absolute; inset: 0; }
ol.chapters .chap-n {
  position: absolute; left: 1rem; top: 1.05rem;
  font-family: var(--mono); font-size: .8rem; color: var(--accent);
}
ol.chapters .date { display: block; font-family: var(--mono); font-size: .7rem; color: var(--faint); margin-top: .2rem; }
ol.chapters .desc { display: block; font-size: .88rem; color: var(--muted); margin-top: .25rem; }

/* ───────── κεφάλαιο: serif + drop cap ───────── */
body:has(.kicker) article { font-family: var(--serif); font-size: 1.13rem; line-height: 1.85; hyphens: manual; }
body:has(.kicker) article p + p { margin-top: .9rem; text-indent: 1.4em; }
body:has(.kicker) article hr + p, body:has(.kicker) article h2 + p, body:has(.kicker) article h3 + p { text-indent: 0; }
body:has(.kicker) article > p:first-child::first-letter {
  float: left; font-size: 3.6em; line-height: .82; font-weight: 600;
  margin: .08em .1em 0 0; color: var(--accent);
}
/* οι επεξηγήσεις όρων στο τέλος γυρίζουν σε sans, μικρότερα */
body:has(.kicker) article h2 ~ * { font-family: var(--sans); font-size: .95rem; line-height: 1.7; text-indent: 0; }
body:has(.kicker) article h2 ~ h3 { font-size: .98rem; }
body:has(.kicker) article h2 { font-family: var(--sans); }

nav.chapter-nav {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; gap: .75rem;
  margin-top: 3.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border);
  font-family: var(--mono); font-size: .74rem; line-height: 1.5;
}
nav.chapter-nav a {
  color: var(--faint); border: 1px solid var(--border); border-radius: 10px;
  padding: .8rem .9rem; background: none;
  transition: border-color .2s, color .2s;
}
nav.chapter-nav a:hover { border-color: var(--accent); color: var(--accent); }
nav.chapter-nav a span {
  display: block; margin-top: .25rem;
  font-family: var(--sans); font-size: .92rem; font-weight: 550; color: var(--text);
}
nav.chapter-nav .prev { grid-column: 1; }
nav.chapter-nav .up { grid-column: 2; align-self: center; border-color: transparent; text-align: center; }
nav.chapter-nav .next { grid-column: 3; text-align: right; }

/* μπάρα προόδου ανάγνωσης (δημιουργείται από το site.js) */
.read-progress {
  position: fixed; left: 0; top: 0; z-index: 30;
  height: 2px; width: 100%;
  background: var(--accent);
  transform-origin: 0 50%; transform: scaleX(0);
}

/* ───────── footer ───────── */
footer {
  clear: both;
  margin-top: 4rem; padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem 1.5rem;
  font-family: var(--mono); font-size: .72rem; color: var(--faint);
}
.status { display: inline-flex; align-items: center; gap: .5rem; }
.status .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #4caf72; animation: ping 2.8s var(--ease) infinite;
}
@keyframes ping {
  0% { box-shadow: 0 0 0 0 rgba(76, 175, 114, .45); }
  70%, 100% { box-shadow: 0 0 0 6px rgba(76, 175, 114, 0); }
}

/* ───────── είσοδος ───────── */
/* καθαρό CSS, χωρίς JS → κανένα τρεμόπαιγμα πριν φορτώσει το script */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
body > h1, .sub, body > section, body > .kicker, body > .date, body > article {
  animation: rise .7s var(--ease) both;
}
.sub { animation-delay: .08s; }
body > section:nth-of-type(1), body > .date { animation-delay: .16s; }
body > section:nth-of-type(2), body > article { animation-delay: .24s; }
body > section:nth-of-type(3) { animation-delay: .32s; }

/* ───────── κινητά ───────── */
@media (max-width: 34em) {
  body > nav.langs { float: none; display: flex; margin: .9rem 0 0; }
  nav.chapter-nav { grid-template-columns: 1fr 1fr; }
  nav.chapter-nav .up { grid-column: 1 / -1; grid-row: 2; }
  nav.chapter-nav .next { grid-column: 2; }
  nav.chapter-nav .prev:only-of-type { grid-column: 1; }
  .posts li { grid-template-columns: 1fr; }
  .posts .date { grid-row: 1; margin-bottom: .1rem; }
  .copy-btn { opacity: 1; }
}

/* ───────── desktop ───────── */
@media (min-width: 52em) {
  .site-logo { position: fixed; top: calc(3rem + env(safe-area-inset-top, 0px)); left: 2rem; margin: 0; }
  .site-logo svg, .site-logo img { width: 3.25rem; height: 3.25rem; }
  nav.top { display: none; }
  body > h1 { margin-top: .25rem; }
  .sub { margin-bottom: 3.5rem; }
  body:not(:has(> article)) > h1 + nav.top + nav.side + section { margin-top: 3rem; }
  nav.side {
    display: flex; flex-direction: column; gap: .85rem;
    position: fixed; top: 50%; left: 2rem; transform: translateY(-50%);
    font-family: var(--mono); font-size: .78rem;
  }
  nav.side a { position: relative; }
  nav.side a::before {
    content: ""; position: absolute; left: -.9rem; top: 50%;
    width: 4px; height: 4px; margin-top: -2px; border-radius: 50%;
    background: var(--accent); opacity: 0; transform: scale(0);
    transition: opacity .25s, transform .25s var(--ease);
  }
  nav.side a.active::before, nav.side a.cur::before { opacity: 1; transform: scale(1); }
  body > nav.langs { margin-right: 0; }
  nav.side .langs { flex-direction: column; gap: .55rem; font-size: .74rem; }
  .side-spacer { display: block; height: 1rem; width: 1px; background: var(--border); margin-left: 1px; }
}
@media (min-width: 52em) and (max-width: 64em) {
  body:not(:has(> article)) { padding-left: 8rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
@media print {
  nav, .theme-toggle, .site-logo, .read-progress, .copy-btn, a.top { display: none !important; }
  body { background: #fff !important; color: #000; max-width: none; }
  article { color: #000; }
}
