@import url('https://fonts.googleapis.com/css2?family=Zilla+Slab:ital,wght@0,400;0,600;0,700;1,400&family=Inconsolata:wght@400;500;600&display=swap');

/* ── Variables ────────────────────────────────────────────── */
:root {
  --bg:         #fbf1c7;
  --bg2:        #f2e5bc;
  --surface:    #ebdbb2;
  --border:     #d5c4a1;
  --text:       #3c3836;
  --muted:      #7c6f64;
  --accent:     #98971a;
  --orange:     #d65d0e;
  --yellow:     #b57614;
  --green:      #427b58;
  --purple:     #8f3f71;
  --visited:    #b57614;
  --selection:  #af3a03;
  --radius:     6px;
}
.video-embed {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  margin: 1.5rem 0;
}
.video-embed iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border-radius: 6px;
}

::selection {
  background: var(--selection);
  color: var(--bg);
}

.dark {
  --bg:      #1d2021;
  --bg2:     #282828;
  --surface: #32302f;
  --border:  #504945;
  --text:    #fbf1c7;
  --muted:   #a89984;
  --accent:  #98971a;
  --orange:  #fe8019;
  --yellow:  #fabd2f;
  --green:   #8ec07c;
  --purple:  #d3869b;
  --visited: #d3869b;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inconsolata', monospace;
  font-size: 18px;
  line-height: 1.7;
  transition: background 0.2s, color 0.2s;
  min-height: 100vh;
}

/* ── Reading Progress ─────────────────────────────────────── */
#reading-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  background: var(--orange);
  z-index: 1000;
  transition: width 0.1s;
  width: 0%;
}

/* ── Wrapper ──────────────────────────────────────────────── */
.site-wrapper {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Header ───────────────────────────────────────────────── */
.site-header {
  padding: 48px 0 32px;
}

.header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
}

.brand { cursor: pointer; }

.brand-name {
  display: block;
  font-family: 'Zilla Slab', serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--orange);
  line-height: 1.1;
}

.brand-sub {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 4px;
  font-style: italic;
}

/* ── Theme Button ─────────────────────────────────────────── */
.theme-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  margin-top: 4px;
  transition: color 0.15s;
}

.theme-btn:hover { color: var(--text); }
.theme-btn svg   { width: 18px; height: 18px; display: block; }
.hidden          { display: none !important; }

/* ── Nav ──────────────────────────────────────────────────── */
.site-nav {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.site-nav a {
  font-family: 'Inconsolata', monospace;
  font-size: 0.9rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.site-nav a:hover { color: var(--orange); }

/* ── Search ───────────────────────────────────────────────── */
.search-wrap { position: relative; }

.search-box {
  width: 100%;
  padding: 8px 0;
  font-family: 'Inconsolata', monospace;
  font-size: 0.9rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.search-box::placeholder { color: var(--muted); }
.search-box:focus { border-bottom-color: var(--orange); }

/* ── Sections ─────────────────────────────────────────────── */
.section {
  padding: 40px 0;
  border-top: 1px solid var(--border);
}

.section:first-child { border-top: none; }

.section-title {
  font-family: 'Zilla Slab', serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--orange);
  text-transform: lowercase;
  margin-bottom: 20px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.section-count {
  font-family: 'Inconsolata', monospace;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 400;
}

/* ── List Items ───────────────────────────────────────────── */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.list-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}

.list-item:last-child { border-bottom: none; }

.item-title {
  font-family: 'Inconsolata', monospace;
  font-size: 0.95rem;
  color: var(--text);
  text-decoration-color: var(--accent);
  text-decoration-thickness: 0.15ex;
  text-underline-offset: 0.3ex;
  flex: 1;
  line-height: 1.4;
}

.item-title:hover { color: var(--orange); }
.item-title:visited { color: var(--visited); }

.item-meta-right {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-shrink: 0;
}

.item-domain {
  font-size: 0.75rem;
  color: var(--accent);
  font-style: italic;
}

.item-date {
  font-size: 0.75rem;
  color: var(--muted);
  font-style: italic;
  flex-shrink: 0;
  white-space: nowrap;
}

.item-desc {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 4px 0 10px;
  line-height: 1.5;
}

.video-item .item-title { color: var(--yellow); }
.video-item .item-title:hover { color: var(--orange); }

.empty {
  color: var(--muted);
  font-size: 0.85rem;
  font-style: italic;
  padding: 8px 0;
}

/* ── Loading ──────────────────────────────────────────────── */
.loading {
  display: flex;
  justify-content: center;
  padding: 32px 0;
}

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── About ────────────────────────────────────────────────── */
.about-section { padding-bottom: 20px; }

.about-content { display: flex; flex-direction: column; gap: 16px; }

.about-main {
  font-family: 'Zilla Slab', serif;
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--text);
}

.about-body {
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.7;
}

/* ── Still Writing Blink ──────────────────────────────────── */
.still-writing {
  font-size: 0.85rem;
  color: var(--accent);
  font-style: italic;
  padding: 12px 0;
}

.blink {
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── CV ───────────────────────────────────────────────────── */
.cv-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.cv-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Inconsolata', monospace;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--bg);
  background: var(--text);
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s;
}

.cv-btn:hover { opacity: 0.8; }
.cv-btn svg   { width: 14px; height: 14px; }

.cv-note {
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
}

/* ── Socials ──────────────────────────────────────────────── */
.socials {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.socials a {
  font-family: 'Inconsolata', monospace;
  font-size: 0.85rem;
  color: var(--green);
  text-decoration-color: var(--green);
  text-underline-offset: 0.3ex;
}

.socials a:hover { opacity: 0.75; }

/* ── Tip ──────────────────────────────────────────────────── */
.tip-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.tip-wrap p {
  font-size: 0.85rem;
  color: var(--muted);
}

.tip-btn {
  font-family: 'Inconsolata', monospace;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s;
}

.tip-btn:hover { border-color: var(--text); }

/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 32px 0 48px;
  font-size: 0.78rem;
  color: var(--muted);
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}

.site-footer a {
  color: var(--green);
  text-decoration-color: var(--green);
}

.footer-dot { color: var(--border); }

/* ── Article View ─────────────────────────────────────────── */
.article-wrap { padding: 32px 0 40px; }

.back-btn {
  display: inline-block;
  font-family: 'Inconsolata', monospace;
  font-size: 0.85rem;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-bottom: 32px;
  transition: color 0.15s;
  text-decoration: none;
}

.back-btn:hover { color: var(--orange); }

.article-meta {
  display: flex;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.article-img {
  margin-bottom: 24px;
  border-radius: var(--radius);
  overflow: hidden;
}

.article-img img {
  width: 100%;
  aspect-ratio: 2 / 1;
  object-fit: contain;
  display: block;
}

.article-img img.loaded { opacity: 1; }

.article-title {
  font-family: 'Zilla Slab', serif;
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 700;
  line-height: 1.3;
  color: var(--orange);
  margin-bottom: 10px;
}

.article-desc {
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 24px;
  line-height: 1.6;
}

/* ── Article Body ─────────────────────────────────────────── */
.article-body {
  font-family: 'Inconsolata', monospace;
  font-size: 0.95rem;
  line-height: 1.9;
  color: var(--text);
  margin-top: 24px;
  border-top: 1px dashed var(--border);
  padding-top: 24px;
}

.article-body h1 { font-size: 1.9rem; color: var(--orange); }
.article-body h2 { font-size: 1.6rem; color: var(--yellow); }
.article-body h3 { font-size: 1.35rem; color: var(--green); }
.article-body h4 { font-size: 1.15rem; color: var(--green); }
.article-body h5 { font-size: 1rem;    color: var(--purple); }

.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4,
.article-body h5 {
  font-family: 'Zilla Slab', serif;
  font-weight: 700;
  line-height: 1.3;
  margin: 1.6em 0 0.4em;
}

.article-body p      { margin-bottom: 1.2em; }
.article-body strong { font-weight: 700; }
.article-body em     { font-style: italic; }

.article-body a {
  color: currentColor;
  text-decoration-color: var(--accent);
}

.article-body a:hover   { opacity: 0.75; }
.article-body a:visited { color: var(--visited); }

.article-body blockquote {
  margin: 1.4em 0;
  padding-left: 1.2em;
  border-left: 2px solid var(--accent);
  color: var(--muted);
  font-style: italic;
}

.article-body pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  overflow-x: auto;
  font-size: 0.85rem;
  margin: 1.4em 0;
  line-height: 1.4;
}

.article-body code {
  background: var(--surface);
  padding: 0.15em 0.35em;
  border-radius: 3px;
  font-size: 0.87em;
}

.article-body pre code { background: none; padding: 0; }

.article-body ul,
.article-body ol {
  padding-left: 1.4em;
  margin-bottom: 1.2em;
}

.article-body li { margin-bottom: 0.3em; }

.article-body img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 1.4em auto;
  display: block;
}

.article-body hr {
  border: none;
  border-top: 1px dashed var(--border);
  margin: 2em 0;
}

/* ── Share ────────────────────────────────────────────────── */
.share-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px dashed var(--border);
  font-size: 0.82rem;
  color: var(--muted);
}

.share-btn {
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}

.share-btn svg   { width: 14px; height: 14px; }
.share-btn:hover { border-color: var(--muted); color: var(--text); }

/* ── Related ──────────────────────────────────────────────── */
.related-wrap {
  padding: 32px 0 20px;
  border-top: 1px solid var(--border);
}

.related-title {
  font-family: 'Zilla Slab', serif;
  font-size: 0.9rem;
  color: var(--orange);
  margin-bottom: 16px;
  font-weight: 700;
}

/* ── Modal ────────────────────────────────────────────────── */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.open        { display: flex; }
.modal-backdrop    {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
}

.modal-box {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 800px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  padding: 16px;
}

.modal-small {
  max-width: 340px;
  border-radius: var(--radius);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  font-family: 'Inconsolata', monospace;
  font-size: 0.88rem;
  color: var(--text);
}

.modal-close {
  position: absolute;
  top: 12px; right: 12px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  transition: color 0.15s;
  line-height: 1;
}

.modal-close:hover    { color: var(--text); }
.modal-close-sm       { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.9rem; }
.modal-close-sm:hover { color: var(--text); }

.video-wrap {
  aspect-ratio: 16/9;
  background: black;
  border-radius: 4px;
  overflow: hidden;
}

.video-wrap iframe { width: 100%; height: 100%; }

/* ── Amount Grid ──────────────────────────────────────────── */
.amount-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.amount-btn {
  padding: 8px 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Inconsolata', monospace;
  font-size: 0.78rem;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}

.amount-btn:hover { border-color: var(--muted); }

.amount-btn.selected {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.custom-wrap {
  position: relative;
  margin-bottom: 12px;
}

.currency {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  font-size: 0.78rem;
  color: var(--muted);
}

.custom-input {
  width: 100%;
  padding: 8px 10px 8px 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Inconsolata', monospace;
  font-size: 0.85rem;
  color: var(--text);
  outline: none;
}

.custom-input:focus        { border-color: var(--muted); }
.custom-input::placeholder { color: var(--muted); }

.pay-btn {
  width: 100%;
  padding: 10px;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-family: 'Inconsolata', monospace;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.pay-btn:hover    { opacity: 0.85; }
.pay-btn:disabled { opacity: 0.5; }

.secured {
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 10px;
}

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%) translateY(50px);
  background: var(--text);
  color: var(--bg);
  padding: 8px 16px;
  font-family: 'Inconsolata', monospace;
  font-size: 0.82rem;
  border-radius: var(--radius);
  opacity: 0;
  transition: all 0.2s ease;
  z-index: 200;
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ── Scroll Top ───────────────────────────────────────────── */
.scroll-top {
  position: fixed;
  bottom: 20px; right: 20px;
  width: 36px; height: 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s;
}

.scroll-top.visible {
  opacity: 1;
  pointer-events: auto;
}

.scroll-top:hover { color: var(--text); border-color: var(--muted); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 560px) {
  body              { font-size: 16px; }
  .site-header      { padding: 28px 0 20px; }
  .brand-name       { font-size: 1.4rem; }
  .list-item        { flex-direction: column; gap: 4px; }
  .item-meta-right  { flex-direction: row; }
  .item-date        { align-self: flex-start; }
  .modal-small      { margin: 0 10px; }
}

/* ── Print ────────────────────────────────────────────────── */
@media print {
  body        { background: white; color: black; }
  .site-footer,
  .back-btn,
  .share-row  { display: none; }
}