/* ===== Haiku for Humans — "Ink on Paper" ===== */

:root {
  /* Parchment palette */
  --bg:          #F8F4EE;
  --bg-card:     #FFFCF7;
  --ink:         #2A2520;
  --ink-muted:   #8A8279;
  --ink-light:   #B8B0A6;
  --rule:        #E5DED4;
  --accent:      #C4654A;   /* terracotta — like a hanko seal */
  --accent-glow: rgba(196, 101, 74, 0.12);

  /* Typography */
  --font-haiku:  'Cormorant Garamond', 'Georgia', serif;
  --font-title:  'Fraunces', 'Georgia', serif;
  --font-ui:     'DM Sans', system-ui, sans-serif;

  /* Spacing */
  --space-xs:  0.5rem;
  --space-sm:  1rem;
  --space-md:  1.5rem;
  --space-lg:  3rem;
  --space-xl:  5rem;

  /* Layout */
  --max-w: 1100px;
  --col-max: 480px;
}

/* ===== Reset ===== */

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

/* ===== Base ===== */

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.6;
  position: relative;
}

/* Paper grain texture */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* ===== Header ===== */

.site-header {
  text-align: center;
  padding: var(--space-xl) var(--space-md) var(--space-lg);
  position: relative;
}

.header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
}

.header-mark {
  color: var(--ink-light);
  margin-bottom: var(--space-sm);
  transition: color 0.6s ease;
}

.site-header:hover .header-mark {
  color: var(--accent);
}

.site-title {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: clamp(2rem, 6vw, 3rem);
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--ink);
}

.site-tagline {
  font-family: var(--font-haiku);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--ink-muted);
  margin-top: var(--space-xs);
  letter-spacing: 0.02em;
}

/* ===== Two-Column Layout ===== */

.two-col {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--space-md);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  align-items: start;
}

.col {
  max-width: var(--col-max);
}

.col-heading {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-light);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--rule);
  margin-bottom: 0;
}

.col-empty {
  font-family: var(--font-haiku);
  font-style: italic;
  font-size: 1rem;
  color: var(--ink-light);
  text-align: center;
  padding: var(--space-lg) 0;
}

.col-empty[hidden] {
  display: none;
}

/* ===== Haiku Feed ===== */

.haiku-feed {
  /* No max-width needed, column handles it */
}

/* ===== Haiku Card ===== */

.haiku-card {
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--rule);
  opacity: 0;
  transform: translateY(12px);
  animation: reveal 0.6s ease forwards;
}

.haiku-card:last-child {
  border-bottom: none;
}

@keyframes reveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Stagger animation via JS data attribute */
.haiku-card[data-index="0"] { animation-delay: 0s; }
.haiku-card[data-index="1"] { animation-delay: 0.08s; }
.haiku-card[data-index="2"] { animation-delay: 0.16s; }
.haiku-card[data-index="3"] { animation-delay: 0.24s; }
.haiku-card[data-index="4"] { animation-delay: 0.32s; }
.haiku-card[data-index="5"] { animation-delay: 0.4s; }
.haiku-card[data-index="6"] { animation-delay: 0.48s; }
.haiku-card[data-index="7"] { animation-delay: 0.56s; }
.haiku-card[data-index="8"] { animation-delay: 0.64s; }
.haiku-card[data-index="9"] { animation-delay: 0.72s; }

.haiku-text {
  font-family: var(--font-haiku);
  font-size: clamp(1.15rem, 3vw, 1.35rem);
  font-weight: 400;
  line-height: 1.8;
  text-align: center;
  color: var(--ink);
  white-space: pre-line;
  letter-spacing: 0.01em;
}

.haiku-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.haiku-author {
  font-weight: 500;
}

.haiku-time {
  position: relative;
  padding-left: var(--space-sm);
}

.haiku-time::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--ink-light);
}

/* ===== Upvote Button ===== */

.upvote-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: none;
  border: 1px solid var(--rule);
  border-radius: 100px;
  padding: 0.3rem 0.65rem;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--ink-muted);
  cursor: pointer;
  transition: all 0.25s ease;
  line-height: 1;
  -webkit-user-select: none;
  user-select: none;
}

.upvote-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.upvote-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.upvote-btn.voted {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
  cursor: default;
}

.upvote-btn svg {
  width: 13px;
  height: 13px;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.upvote-btn.voted svg {
  fill: var(--accent);
}

.upvote-btn.pop svg {
  transform: scale(1.35);
}

/* ===== Loader ===== */

.loader {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: var(--space-lg) 0;
}

.loader[hidden] {
  display: none;
}

.loader-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-light);
  animation: pulse 1.2s ease-in-out infinite;
}

.loader-dot:nth-child(2) { animation-delay: 0.15s; }
.loader-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes pulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ===== Empty State ===== */

.empty-state {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
}

.empty-state[hidden] {
  display: none;
}

.empty-icon {
  color: var(--ink-light);
  margin-bottom: var(--space-sm);
}

.empty-text {
  font-family: var(--font-haiku);
  font-style: italic;
  font-size: 1.25rem;
  color: var(--ink-muted);
}

.empty-sub {
  font-size: 0.85rem;
  color: var(--ink-light);
  margin-top: var(--space-xs);
}

/* ===== Telegram CTA (floating pill) ===== */

.telegram-cta {
  position: fixed;
  bottom: var(--space-md);
  right: var(--space-md);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.7rem 1.2rem;
  border-radius: 100px;
  text-decoration: none;
  box-shadow: 0 4px 20px rgba(42, 37, 32, 0.15);
  transition: all 0.3s ease;
  z-index: 100;
}

.telegram-cta:hover {
  background: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(196, 101, 74, 0.25);
}

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

.telegram-icon {
  flex-shrink: 0;
}

/* ===== Footer ===== */

.site-footer {
  text-align: center;
  padding: var(--space-xl) var(--space-md) var(--space-lg);
  font-size: 0.8rem;
  color: var(--ink-light);
  max-width: var(--max-w);
  margin: 0 auto;
}

.site-footer a {
  color: var(--ink-muted);
  text-decoration-color: var(--rule);
  text-underline-offset: 3px;
  transition: color 0.2s;
}

.site-footer a:hover {
  color: var(--accent);
}

/* ===== Responsive ===== */

@media (max-width: 768px) {
  .two-col {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  .col {
    max-width: none;
  }
}

@media (max-width: 480px) {
  .site-header {
    padding: var(--space-lg) var(--space-sm) var(--space-md);
  }

  .two-col {
    padding: 0 var(--space-sm);
  }

  .telegram-cta span {
    display: none;
  }

  .telegram-cta {
    padding: 0.8rem;
    border-radius: 50%;
  }
}

/* ===== Print ===== */

@media print {
  .grain, .telegram-cta, .upvote-btn, .loader { display: none; }
  .haiku-card { break-inside: avoid; opacity: 1; transform: none; animation: none; }
}
