/* ===========================================
   vini-terminal — a Unix terminal Hugo theme
   =========================================== */

/* Font loaded via <link> in baseof.html for faster non-blocking fetch */

/* ---- Tokens ---- */
:root {
  --font: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Cascadia Code', monospace;
  --fs: 15px;
  --lh: 1.7;
  --max-w: 56rem;
  --radius: 4px;
  --speed: .25s ease;

  /* dark (default) */
  --bg:         #0e1116;
  --bg-surface: #161b22;
  --bg-hover:   #1c2129;
  --fg:         #c9d1d9;
  --fg-bright:  #f0f3f6;
  --fg-muted:   #6e7681;
  --border:     #30363d;
  --green:      #3fb950;
  --blue:       #58a6ff;
  --amber:      #d29922;
  --red:        #f85149;
  --purple:     #bc8cff;
  --cyan:       #39c5cf;
  --link:       #58a6ff;
  --link-h:     #79c0ff;
  --prompt:     #3fb950;
  --sel:        #264f78;
  --code-bg:    #161b22;
  --sb-thumb:   #30363d;
  --sb-track:   #0e1116;
  color-scheme: dark;
}

/* light — system preference */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg:         #f6f5f0;
    --bg-surface: #eceae3;
    --bg-hover:   #e3e1d9;
    --fg:         #2f3337;
    --fg-bright:  #1a1d20;
    --fg-muted:   #7c8087;
    --border:     #d0cec7;
    --green:      #1a7f37;
    --blue:       #0969da;
    --amber:      #9a6700;
    --red:        #cf222e;
    --purple:     #8250df;
    --cyan:       #0598bc;
    --link:       #0969da;
    --link-h:     #0550ae;
    --prompt:     #1a7f37;
    --sel:        #b6d3f0;
    --code-bg:    #eceae3;
    --sb-thumb:   #c5c3bc;
    --sb-track:   #f6f5f0;
    color-scheme: light;
  }
}

/* light — manual override */
:root[data-theme="light"] {
  --bg:         #f6f5f0;
  --bg-surface: #eceae3;
  --bg-hover:   #e3e1d9;
  --fg:         #2f3337;
  --fg-bright:  #1a1d20;
  --fg-muted:   #7c8087;
  --border:     #d0cec7;
  --green:      #1a7f37;
  --blue:       #0969da;
  --amber:      #9a6700;
  --red:        #cf222e;
  --purple:     #8250df;
  --cyan:       #0598bc;
  --link:       #0969da;
  --link-h:     #0550ae;
  --prompt:     #1a7f37;
  --sel:        #b6d3f0;
  --code-bg:    #eceae3;
  --sb-thumb:   #c5c3bc;
  --sb-track:   #f6f5f0;
  color-scheme: light;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: var(--fs); -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  line-height: var(--lh);
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--speed), color var(--speed);
  overflow-x: hidden;
}

::selection { background: var(--sel); color: var(--fg-bright); }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--sb-track); }
::-webkit-scrollbar-thumb { background: var(--sb-thumb); border-radius: 4px; }

/* ---- Layout ---- */
.wrap {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2rem 1.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.site-main { flex: 1; }

/* ---- Header ---- */
.site-header {
  margin-bottom: 3rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.prompt {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0;
  font-size: 1rem;
  margin-bottom: 1rem;
  word-break: break-all;
}
.prompt-user  { color: var(--prompt); font-weight: 700; }
.prompt-at    { color: var(--fg-muted); }
.prompt-host a {
  color: var(--cyan);
  font-weight: 700;
  text-decoration: none;
}
.prompt-host a:hover { text-decoration: underline; }
.prompt-colon { color: var(--fg-muted); }
.prompt-path  { color: var(--blue); font-weight: 700; }
.prompt-dollar { color: var(--fg-bright); font-weight: 700; margin-left: .35ch; }

.cursor {
  display: inline-block;
  width: .6em;
  height: 1.15em;
  background: var(--fg-bright);
  vertical-align: text-bottom;
  margin-left: .3ch;
  animation: blink 1s step-end infinite;
}
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

/* Nav */
.site-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
}
.site-nav a {
  color: var(--fg);
  text-decoration: none;
  padding: .2rem 0;
  margin-right: 1.5rem;
  transition: color var(--speed);
}
.site-nav a:hover,
.site-nav a[aria-current] { color: var(--link); }
.site-nav a::before { content: '~/'; color: var(--fg-muted); font-size: .85em; }

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  font-family: var(--font);
  font-size: .85rem;
  padding: .1rem .5rem;
  cursor: pointer;
  border-radius: var(--radius);
  margin-left: auto;
  transition: color var(--speed), border-color var(--speed);
  line-height: 1.6;
}
.theme-toggle:hover { color: var(--fg); border-color: var(--fg-muted); }

/* ---- Footer ---- */
.site-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: .85rem;
}
.site-footer a { color: var(--fg-muted); text-decoration: none; transition: color var(--speed); }
.site-footer a:hover { color: var(--fg); }

/* ---- Typography ---- */
h1, h2, h3, h4, h5, h6 {
  color: var(--fg-bright);
  font-weight: 700;
  line-height: 1.3;
  margin: 1.5em 0 .5em;
}
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }

/* markdown heading prefixes */
.prose h1::before { content: '# ';  color: var(--fg-muted); font-weight: 400; }
.prose h2::before { content: '## '; color: var(--fg-muted); font-weight: 400; }
.prose h3::before { content: '### '; color: var(--fg-muted); font-weight: 400; }

.page-title { font-size: 1.5rem; margin-top: 0; margin-bottom: .25rem; }

p { margin: 1em 0; }

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--speed);
}
a:hover { color: var(--link-h); }

strong { color: var(--fg-bright); font-weight: 700; }
em { font-style: italic; }

hr { border: none; border-top: 1px dashed var(--border); margin: 2rem 0; }

blockquote {
  border-left: 3px solid var(--border);
  padding-left: 1rem;
  color: var(--fg-muted);
  margin: 1.5em 0;
  font-style: italic;
}

/* ---- Code ---- */
code {
  font-family: var(--font);
  font-size: .9em;
  background: var(--code-bg);
  padding: .15em .4em;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  margin: 1.5em 0;
  line-height: 1.5;
}
pre code { background: none; border: none; padding: 0; font-size: .9rem; }

/* ---- Lists ---- */
ul, ol { margin: 1em 0; padding-left: 2em; }
li { margin: .3em 0; }
li::marker { color: var(--fg-muted); }

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; margin: 1.5em 0; font-size: .9rem; }
th, td { padding: .5rem 1rem; border: 1px solid var(--border); text-align: left; }
th { color: var(--fg-bright); background: var(--bg-surface); }

/* ---- Images ---- */
img { max-width: 100%; height: auto; border-radius: var(--radius); }
figure { margin: 1.5em 0; }
figcaption { color: var(--fg-muted); font-size: .85rem; margin-top: .5rem; }

/* ---- Post Meta ---- */
.post-meta {
  color: var(--fg-muted);
  font-size: .85rem;
  margin-bottom: 2rem;
}
.post-meta time { color: var(--amber); }

/* ---- Posts List ---- */
.posts-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
}
.posts-list li {
  padding: .6rem 0;
  border-bottom: 1px solid transparent;
  transition: border-color var(--speed);
}
.posts-list li:hover { border-bottom-color: var(--border); }
.post-line {
  display: flex;
  align-items: baseline;
  gap: 1rem;
}
.post-line .title { flex: 1; min-width: 0; }
.excerpt {
  color: var(--fg-muted);
  font-size: .85rem;
  margin-top: .25rem;
  line-height: 1.5;
}
.excerpt p { margin: 0; }

.posts-list .date {
  color: var(--fg-muted);
  font-size: .85rem;
  flex-shrink: 0;
  min-width: 7rem;
}
.posts-list .title a {
  color: var(--fg);
  text-decoration: none;
}
.posts-list .title a:hover { color: var(--link); }

.posts-list .external-link::after {
  content: ' \2197';
  color: var(--fg-muted);
  font-size: .8em;
}

/* ---- Archive Link Icon ---- */
.archive-link {
  display: inline-flex;
  align-items: center;
  margin-left: .35rem;
  color: var(--fg-muted);
  text-decoration: none;
  transition: color var(--speed);
  vertical-align: baseline;
}
.archive-link:hover { color: var(--amber); }
.archive-link svg { height: .85em; width: auto; fill: currentColor; }

/* ---- Section Label ---- */
.section-label {
  color: var(--fg-muted);
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: .75rem;
  margin-top: 2.5rem;
}
.section-label::before { content: '\2192 '; color: var(--prompt); }
.section-label:first-child { margin-top: 0; }

/* ---- Photo Grid ---- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .75rem;
  margin: 1.5rem 0;
}
.photo-grid a {
  display: block;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  aspect-ratio: 1;
  transition: border-color var(--speed), transform var(--speed);
}
.photo-grid a:hover { border-color: var(--link); transform: scale(1.02); }
.photo-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
  transition: opacity var(--speed);
}

/* ---- Gallery Single ---- */
.gallery-image {
  width: 100%;
  margin: 1rem 0;
  border: 1px solid var(--border);
}

/* ---- 404 ---- */
.not-found { text-align: center; padding: 4rem 0; }
.not-found h1 { font-size: 3rem; color: var(--red); }

/* ---- Homepage ---- */
.view-all {
  font-size: .85rem;
  color: var(--fg-muted);
  text-decoration: none;
  display: inline-block;
  margin-top: .5rem;
}
.view-all:hover { color: var(--link); }
.view-all::before { content: '$ ls '; color: var(--prompt); }

/* ---- Page Animation ---- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.site-main { animation: fadeUp .3s ease-out; }

/* ---- Responsive ---- */
@media (max-width: 640px) {
  :root { --fs: 14px; }
  .wrap { padding: 1.25rem 1rem; }
  .site-header { margin-bottom: 2rem; }
  .prompt { font-size: .9rem; }
  .post-line { flex-direction: column; gap: .1rem; }
  .posts-list li { padding: .5rem 0; }
  .excerpt { padding-left: 0; }
  .posts-list .date { min-width: auto; font-size: .8rem; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; }
  h1 { font-size: 1.3rem; }
  h2 { font-size: 1.15rem; }
}
