/* ============================================================
   RESET & BASE
   ============================================================ */

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

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

body, h1, h2, h3, h4, h5, h6, p, ul, ol, dl, figure, blockquote, pre {
  margin: 0;
  padding: 0;
}

/* ============================================================
   DESIGN TOKENS — FLEXOKI × MINIMAL
   ============================================================ */

:root {
  /* Flexoki Light */
  --bg1: #FFFFFF;
  --bg2: #F8F8F7;
  --bg3: #F0EFEB;

  --tx1: #100F0F;
  --tx2: #403E3C;
  --tx3: #6F6E69;
  --tx4: #B7B5AC;

  --ui1: #E6E4D9;
  --ui2: #DAD8CE;
  --ui3: #CECDC3;

  --ax1: #1a6560;
  --ax2: #24837B;
  --ax3: #3AA99F;

  --hl1: #F6E2A0;
  --hl2: #FCEFC7;

  --red:    #AF3029;
  --orange: #BC5215;
  --yellow: #AD8301;
  --green:  #66800B;
  --cyan:   #24837B;
  --blue:   #205EA6;
  --purple: #5E409D;
  --magenta: #A02F6F;

  /* Typography */
  --font-text: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Ubuntu, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "IBM Plex Mono", "SF Mono", Menlo, monospace;
  --font-size-base: 1.6rem;
  --line-height: 1.6;
  --p-spacing: 1.75rem;
  --heading-spacing: 2em;

  /* Layout */
  --line-width: 40rem;
  --line-width-wide: 56rem;

  /* Borders & Radius */
  --radius-s: 4px;
  --radius-m: 6px;
  --border-color: var(--ui1);

  /* Transitions */
  --t-fast: 100ms ease;
  --t-normal: 200ms ease;

  /* Icons */
  --icon-sun: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236F6E69' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='5'/%3E%3Cline x1='12' y1='1' x2='12' y2='3'/%3E%3Cline x1='12' y1='21' x2='12' y2='23'/%3E%3Cline x1='4.22' y1='4.22' x2='5.64' y2='5.64'/%3E%3Cline x1='18.36' y1='18.36' x2='19.78' y2='19.78'/%3E%3Cline x1='1' y1='12' x2='3' y2='12'/%3E%3Cline x1='21' y1='12' x2='23' y2='12'/%3E%3Cline x1='4.22' y1='19.78' x2='5.64' y2='18.36'/%3E%3Cline x1='18.36' y1='5.64' x2='19.78' y2='4.22'/%3E%3C/svg%3E");
  --icon-moon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236F6E69' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z'/%3E%3C/svg%3E");
}

/* Dark mode overrides */
.theme-dark {
  --bg1: #100F0F;
  --bg2: #1C1B1A;
  --bg3: #282726;

  --tx1: #CECDC3;
  --tx2: #B7B5AC;
  --tx3: #878580;
  --tx4: #575653;

  --ui1: #282726;
  --ui2: #343230;
  --ui3: #403E3C;

  --ax1: #4dbdb3;
  --ax2: #3AA99F;
  --ax3: #24837B;

  --hl1: #3D3822;
  --hl2: #2A2A1A;

  --red:    #D14D41;
  --orange: #DA702C;
  --yellow: #D0A215;
  --green:  #879A39;
  --cyan:   #3AA99F;
  --blue:   #4385BE;
  --purple: #8B7EC8;
  --magenta: #CE5D97;

  --border-color: var(--ui1);

  --icon-sun: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23878580' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='5'/%3E%3Cline x1='12' y1='1' x2='12' y2='3'/%3E%3Cline x1='12' y1='21' x2='12' y2='23'/%3E%3Cline x1='4.22' y1='4.22' x2='5.64' y2='5.64'/%3E%3Cline x1='18.36' y1='18.36' x2='19.78' y2='19.78'/%3E%3Cline x1='1' y1='12' x2='3' y2='12'/%3E%3Cline x1='21' y1='12' x2='23' y2='12'/%3E%3Cline x1='4.22' y1='19.78' x2='5.64' y2='18.36'/%3E%3Cline x1='18.36' y1='5.64' x2='19.78' y2='4.22'/%3E%3C/svg%3E");
  --icon-moon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23878580' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z'/%3E%3C/svg%3E");
}

/* ============================================================
   BODY
   ============================================================ */

body {
  background-color: var(--bg1);
  color: var(--tx1);
  font-family: var(--font-text);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  transition: background-color var(--t-normal), color var(--t-normal);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */

/* Heading scale — proportional like Minimal (tight, not dramatic) */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-text);
  color: var(--tx1);
  font-weight: 600;
  line-height: 1.3;
}

h1 { font-size: 1.8em;  margin-top: 0;                    margin-bottom: 0.75rem; }
h2 { font-size: 1.35em; margin-top: var(--heading-spacing); margin-bottom: 0.5rem;  }
h3 { font-size: 1.15em; margin-top: 1.6em;                 margin-bottom: 0.4rem;  }
h4 { font-size: 1.05em; margin-top: 1.4em;                 margin-bottom: 0.3rem;  }
h5 { font-size: 0.95em; margin-top: 1.2em;                 margin-bottom: 0.3rem; font-weight: 500; }
h6 { font-size: 0.85em; margin-top: 1.2em;                 margin-bottom: 0.3rem; font-weight: 400; color: var(--tx3); }

p {
  margin-top: 0;
  margin-bottom: var(--p-spacing);
}

p:last-child {
  margin-bottom: 0;
}

/* Links — no underline by default (Minimal approach) */
a {
  color: var(--ax2);
  text-decoration: none;
  transition: color var(--t-fast);
}

a:hover {
  color: var(--ax1);
}

/* Inline text */
strong { font-weight: 600; }
em     { font-style: italic; }

mark {
  background: var(--hl1);
  color: var(--tx1);
  padding: 0.05em 0.2em;
  border-radius: 2px;
}

/* Lists */
ul, ol {
  padding-left: 1.8em;
  margin-bottom: var(--p-spacing);
}

li {
  margin-bottom: 0.2em;
  line-height: var(--line-height);
}

li > ul,
li > ol {
  margin-top: 0.2em;
  margin-bottom: 0;
}

/* Blockquote */
blockquote {
  border-left: 2px solid var(--ui3);
  margin: 1.5em 0;
  padding: 0.2em 0 0.2em 1.2em;
  color: var(--tx3);
}

blockquote p:last-child {
  margin-bottom: 0;
}

/* Code */
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--ui1);
  color: var(--tx2);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-s);
}

pre {
  background: var(--bg2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-m);
  padding: 1.2em 1.5em;
  overflow-x: auto;
  margin: 1.5em 0;
  line-height: 1.5;
}

pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 0.875em;
  color: inherit;
}

/* HR */
hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 2.5em 0;
}

/* Images */
img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-s);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.9em;
}

th, td {
  text-align: left;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-color);
}

th {
  font-weight: 600;
  color: var(--tx3);
  font-size: 0.85em;
  letter-spacing: 0.03em;
}

tr:last-child td {
  border-bottom: none;
}

/* ============================================================
   LAYOUT
   ============================================================ */

.wrap {
  max-width: var(--line-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: 2rem;
  padding-right: 2rem;
}

.wide {
  max-width: var(--line-width-wide);
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */

.flex           { display: flex; }
.flex-col       { flex-direction: column; }
.align-center   { align-items: center; }
.flex-grow      { flex: 1; }
.gap-sm         { gap: 0.8rem; }
.gap-md         { gap: 1.6rem; }

/* Text tiers */
.tx1            { color: var(--tx1); }
.tx2            { color: var(--tx2); }
.muted          { color: var(--tx3); }
.faint          { color: var(--tx4); }
.accent         { color: var(--ax2); }

.small          { font-size: 0.875em; }
.smaller        { font-size: 0.8em; }
.mono           { font-family: var(--font-mono); }
.caps           { font-size: 0.78em; letter-spacing: 0.07em; text-transform: uppercase; font-weight: 500; }

/* Padding top */
.pn1 { padding-top: 1.6rem; }
.pn2 { padding-top: 3rem;   }
.pn3 { padding-top: 5rem;   }
.pn4 { padding-top: 8rem;   }

/* Padding bottom */
.ps1 { padding-bottom: 1.6rem; }
.ps2 { padding-bottom: 3rem;   }
.ps3 { padding-bottom: 5rem;   }
.ps4 { padding-bottom: 8rem;   }

/* Margin top */
.mn1 { margin-top: 1.6rem; }
.mn2 { margin-top: 3rem;   }
.mn3 { margin-top: 5rem;   }
.mn4 { margin-top: 8rem;   }

/* Margin bottom */
.ms1 { margin-bottom: 1.6rem; }
.ms2 { margin-bottom: 3rem;   }
.ms3 { margin-bottom: 5rem;   }
.ms4 { margin-bottom: 8rem;   }

/* ============================================================
   NAVIGATION
   ============================================================ */

.site-nav {
  padding: 2.4rem 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 5rem;
}

.site-nav .wrap {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.site-name {
  font-weight: 600;
  font-size: 1em;
  color: var(--tx1);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.site-name:hover {
  color: var(--tx1);
}

.breadcrumb {
  color: var(--tx3);
  font-size: 0.9em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.8rem;
  margin-left: auto;
}

.nav-links a {
  font-size: 0.9em;
  color: var(--tx3);
  text-decoration: none;
  transition: color var(--t-fast);
}

.nav-links a:hover {
  color: var(--tx1);
}

/* ============================================================
   THEME TOGGLE
   ============================================================ */

.theme-toggle {
  background: none;
  border: 1px solid var(--ui3);
  border-radius: 20px;
  cursor: pointer;
  width: 44px;
  height: 24px;
  padding: 0;
  position: relative;
  flex-shrink: 0;
  transition: border-color var(--t-fast);
  outline: none;
}

.theme-toggle:hover {
  border-color: var(--tx4);
}

.theme-toggle:focus-visible {
  box-shadow: 0 0 0 2px var(--ax2);
}

.theme-toggle::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background-color: var(--tx3);
  -webkit-mask-image: var(--icon-sun);
  mask-image: var(--icon-sun);
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  transition: left var(--t-normal);
}

.theme-dark .theme-toggle::before {
  left: calc(100% - 18px);
  -webkit-mask-image: var(--icon-moon);
  mask-image: var(--icon-moon);
}

/* ============================================================
   POSTS LIST
   ============================================================ */

.posts-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.posts-list li {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 1.2rem;
  align-items: baseline;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border-color);
  margin: 0;
}

.posts-list li:first-child {
  border-top: 1px solid var(--border-color);
}

.post-date {
  font-size: 0.8em;
  color: var(--tx4);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  padding-top: 0.1em;
}

.post-title-link {
  color: var(--tx1);
  text-decoration: none;
  transition: color var(--t-fast);
}

.post-title-link:hover {
  color: var(--ax2);
}

/* Featured post */
.post-featured {
  margin-bottom: 4rem;
  padding-bottom: 4rem;
  border-bottom: 1px solid var(--border-color);
}

.post-featured h2 {
  margin-top: 0;
  font-size: 1.5em;
}

.post-featured h2 a {
  color: var(--tx1);
  text-decoration: none;
}

.post-featured h2 a:hover {
  color: var(--ax2);
}

.post-description {
  color: var(--tx3);
  margin-top: 0.4em;
  font-size: 0.95em;
}

/* ============================================================
   ARTICLE (post page)
   ============================================================ */

article.post {
  max-width: var(--line-width);
}

.post-header {
  margin-bottom: 4rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--border-color);
}

.post-header h1 {
  font-size: 2em;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}

.post-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.8rem;
  color: var(--tx4);
  font-size: 0.85em;
}

.post-meta time {
  color: var(--tx4);
}

.post-meta .sep {
  color: var(--ui3);
}

/* Post body */
.post-content {
  color: var(--tx2);
}

.post-content > * + * {
  margin-top: var(--p-spacing);
}

.post-content p,
.post-content li {
  color: var(--tx2);
}

.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
  color: var(--tx1);
  position: relative;
}

/* Anchor links */
.post-content .anchor {
  position: absolute;
  left: -1.4em;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  color: var(--tx4);
  text-decoration: none;
  font-weight: 400;
  font-size: 0.9em;
  transition: opacity var(--t-fast), color var(--t-fast);
  user-select: none;
}

.post-content h2:hover .anchor,
.post-content h3:hover .anchor,
.post-content h4:hover .anchor,
.post-content h5:hover .anchor,
.post-content h6:hover .anchor {
  opacity: 1;
}

.post-content .anchor:hover {
  color: var(--ax2);
}

/* External links — arrow icon */
.post-content a:not(.anchor):not(.tag):not([href^="/"]):not([href^="#"]):not([href^="mailto"]) {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='9' viewBox='0 0 24 24' fill='none' stroke='%2324837B' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'/%3E%3Cpolyline points='15 3 21 3 21 9'/%3E%3Cline x1='10' y1='14' x2='21' y2='3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.15em top 35%;
  background-size: 0.7em;
  padding-right: 0.95em;
}

/* ============================================================
   TAGS
   ============================================================ */

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag {
  display: inline-block;
  font-size: 0.78em;
  padding: 0.2em 0.65em;
  background: var(--ui1);
  border-radius: var(--radius-s);
  color: var(--tx3);
  text-decoration: none;
  letter-spacing: 0.01em;
  transition: background var(--t-fast), color var(--t-fast);
}

.tag:hover {
  background: var(--ui2);
  color: var(--tx2);
}

/* ============================================================
   RELATED POSTS
   ============================================================ */

.related-posts {
  margin-top: 5rem;
  padding-top: 3rem;
  border-top: 1px solid var(--border-color);
}

.related-posts h2 {
  font-size: 0.78em;
  margin-top: 0;
  margin-bottom: 1.2rem;
  color: var(--tx4);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 500;
}

/* ============================================================
   BACKLINKS
   ============================================================ */

.backlinks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}

.backlink {
  display: block;
  padding: 1rem 1.2rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-m);
  text-decoration: none;
  color: var(--tx1);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}

.backlink:hover {
  border-color: var(--ui3);
  background: var(--bg2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  color: var(--tx1);
}

.backlink-title {
  font-weight: 500;
  font-size: 0.95em;
  display: block;
  margin-bottom: 0.25em;
}

.backlink-desc {
  font-size: 0.82em;
  color: var(--tx3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================================
   TOPICS
   ============================================================ */

.topics-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 2rem;
}

.topics-list li {
  margin: 0;
}

/* ============================================================
   FOOTER
   ============================================================ */

.site-footer {
  margin-top: 8rem;
  padding: 3rem 0 4rem;
  border-top: 1px solid var(--border-color);
}

.footer-label {
  font-size: 0.78em;
  color: var(--tx4);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 500;
  margin-bottom: 1rem;
}

.subscribe-form {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 2.4rem;
}

.subscribe-form input[type="email"] {
  flex: 1;
  min-width: 0;
  padding: 0.5em 0.9em;
  border: 1px solid var(--ui3);
  border-radius: var(--radius-s);
  background: var(--bg1);
  color: var(--tx1);
  font-family: var(--font-text);
  font-size: 0.9em;
  transition: border-color var(--t-fast);
  outline: none;
}

.subscribe-form input[type="email"]:focus {
  border-color: var(--ax2);
}

.subscribe-form input[type="email"]::placeholder {
  color: var(--tx4);
}

.subscribe-form input[type="submit"] {
  padding: 0.5em 1.2em;
  background: var(--tx1);
  color: var(--bg1);
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  font-family: var(--font-text);
  font-size: 0.9em;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
}

.subscribe-form input[type="submit"]:hover {
  background: var(--tx2);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.6rem;
}

.footer-links a {
  font-size: 0.85em;
  color: var(--tx3);
  text-decoration: none;
  transition: color var(--t-fast);
}

.footer-links a:hover {
  color: var(--tx1);
}

/* ============================================================
   STATIC PAGES
   ============================================================ */

article.page h1 {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-color);
}

article.page .page-content {
  color: var(--tx2);
}

/* ============================================================
   404
   ============================================================ */

.page-404 {
  text-align: center;
  padding: 10rem 0;
}

.page-404 h1 {
  font-size: 8rem;
  color: var(--tx4);
  font-weight: 300;
  letter-spacing: -0.04em;
  margin-bottom: 0.2em;
  line-height: 1;
}

.page-404 p {
  color: var(--tx3);
  margin-bottom: 2rem;
}

/* ============================================================
   MEDIA QUERIES
   ============================================================ */

@media (max-width: 600px) {
  :root {
    --font-size-base: 1.55rem;
  }

  .site-nav {
    margin-bottom: 3rem;
  }

  .posts-list li {
    grid-template-columns: 1fr;
    gap: 0.15rem;
    padding: 0.8rem 0;
  }

  .post-date {
    font-size: 0.75em;
  }

  .post-header h1 {
    font-size: 1.6em;
  }

  .backlinks {
    grid-template-columns: 1fr;
  }

  .subscribe-form {
    flex-direction: column;
  }

  .post-content .anchor {
    display: none;
  }

  .nav-links {
    gap: 1.2rem;
  }
}
