/* ==========================================================================
   Tuwuh Coffee — main.css
   Based on docs/design-system.md (warm coffee palette, menu poster identity)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&family=Open+Sans:wght@400;700&display=swap');

:root {
  /* Colors — warm coffee palette anchored on #392D2F (Black Coffee),
     taken from the Tuwuh menu poster identity */
  --color-bg: #F2EAD9;             /* warm cream page background */
  --color-surface: #FFFDF8;        /* warm white cards */
  --color-surface-alt: #F7F1E5;    /* inputs, nested surfaces */
  --color-text: #392D2F;           /* Black Coffee */
  --color-text-muted: #6E5F58;
  --color-primary: #392D2F;        /* primary CTA */
  --color-primary-hover: #2A2123;
  --color-primary-active: #1E1719;
  --color-accent-green: #5F6B3C;   /* olive — Original Series */
  --color-accent-orange: #C05621;  /* burnt orange — Orange Spark */
  --color-accent-orange-text: #9C4218; /* darker orange: AA-safe text on light tints */
  --color-border: #E3DACB;
  --color-badge-bg: #EAE2D3;

  /* Fonts */
  --font-heading: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Spacing (4px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-15: 60px;
  --space-25: 100px;

  /* Radius */
  --radius-subtle: 4px;
  --radius-standard: 6px;
  --radius-rounded: 8px;
  --radius-pill: 12px;

  /* Shadows */
  --shadow-1: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-2: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-3: 0 4px 16px rgba(0, 0, 0, 0.12);
  --shadow-4: 0 8px 24px rgba(0, 0, 0, 0.15);

  /* Motion — see docs/design-system.md §10; only animate transform/opacity
     (plus color/background/box-shadow via transition) */
  --motion-fast: 150ms;   /* small hovers: color, opacity */
  --motion-base: 250ms;   /* hover lift, underline, buttons */
  --motion-slow: 400ms;   /* reveal on scroll, hero entrance */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);      /* entrances */
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);  /* state changes */
}

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

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

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

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text);
  background-color: var(--color-bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 700;
}

h1 {
  font-size: 28px;
  line-height: 1.3;
}

h2 {
  font-size: 24px;
  line-height: 1.3;
}

h3 {
  font-size: 20px;
  line-height: 1.3;
}

p {
  font-size: 16px;
  line-height: 1.5;
}

a {
  color: var(--color-accent-green);
}

img {
  max-width: 100%;
}

/* Public pages use the larger reading scale from the design system */
.page-body p,
.page-body li {
  font-size: 20px;
  line-height: 28px;
}

.text-small {
  font-size: 16px;
  line-height: 24px;
}

.text-meta {
  font-size: 14px;
  line-height: 20px;
  color: var(--color-text-muted);
}

/* Layout ================================================================== */

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

.section {
  padding: var(--space-6) 0;
}

.section-title {
  margin-bottom: var(--space-5);
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

/* Buttons ================================================================= */

.btn-primary,
.btn-secondary,
.btn-ghost {
  display: inline-block;
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  line-height: 20px;
  letter-spacing: 0.5px;
  padding: 12px 24px;
  border-radius: var(--radius-subtle);
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition:
    background-color var(--motion-fast) var(--ease-in-out),
    border-color var(--motion-fast) var(--ease-in-out),
    color var(--motion-fast) var(--ease-in-out),
    box-shadow var(--motion-fast) var(--ease-in-out),
    transform var(--motion-fast) var(--ease-out);
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-surface);
  border: none;
}

.btn-primary:hover {
  background: var(--color-primary-hover);
}

.btn-primary:active {
  background: var(--color-primary-active);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
  transform: scale(0.98);
}

.btn-primary:disabled {
  background: var(--color-border);
  color: var(--color-text-muted);
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}

.btn-secondary:hover {
  background: rgba(57, 45, 47, 0.06);
  border-color: var(--color-primary-hover);
}

.btn-secondary:active {
  background: rgba(57, 45, 47, 0.12);
  box-shadow: inset 0 2px 4px rgba(57, 45, 47, 0.15);
  transform: scale(0.98);
}

.btn-ghost {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid transparent;
}

.btn-ghost:hover {
  background: rgba(57, 45, 47, 0.06);
  border: 1px solid var(--color-border);
}

.btn-ghost:active {
  background: rgba(57, 45, 47, 0.12);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

.btn-icon:hover {
  transform: translateY(-2px);
}

/* Cards =================================================================== */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-rounded);
  box-shadow: var(--shadow-2);
  padding: var(--space-5);
  transition:
    transform var(--motion-base) var(--ease-out),
    box-shadow var(--motion-base) var(--ease-out);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-3);
}

/* Admin cards wrap tables and forms — they must stay put */
.admin .card:hover {
  transform: none;
  box-shadow: var(--shadow-2);
}

.card-elevated {
  background: var(--color-surface);
  border: none;
  border-radius: var(--radius-rounded);
  box-shadow: var(--shadow-3);
  padding: var(--space-5);
}

/* Badges ================================================================== */

.badge {
  display: inline-block;
  background: var(--color-border);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  line-height: 16px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  transition:
    background-color var(--motion-fast) var(--ease-in-out),
    color var(--motion-fast) var(--ease-in-out);
}

.badge-primary {
  background: var(--color-badge-bg);
  color: var(--color-text);
}

.badge-green {
  background: rgba(95, 107, 60, 0.14);
  color: var(--color-accent-green);
}

.badge-orange {
  background: rgba(192, 86, 33, 0.12);
  color: var(--color-accent-orange-text);
}

/* Forms =================================================================== */

.form-group {
  margin-bottom: var(--space-4);
}

/* Honeypot — visually gone but still "fillable" for bots (no display:none) */
.hp-field {
  position: absolute;
  left: -9999px;
  opacity: 0;
  pointer-events: none;
}

.form-label {
  display: block;
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
  line-height: 20px;
  color: var(--color-text);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--color-surface-alt);
  color: var(--color-text);
  border: 1px solid rgba(57, 45, 47, 0.25);
  border-radius: var(--radius-subtle);
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  transition:
    border-color var(--motion-fast) var(--ease-in-out),
    box-shadow var(--motion-fast) var(--ease-in-out);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border: 2px solid var(--color-primary);
  box-shadow: 0 0 0 3px rgba(57, 45, 47, 0.15);
  /* keep layout stable when border grows 1px -> 2px */
  padding: 9px 11px;
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
}

.form-helper {
  font-size: 12px;
  line-height: 16px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* Navbar ================================================================== */

.navbar {
  background: var(--color-surface);
  height: 64px;
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-inner {
  max-width: 1440px;
  height: 64px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.navbar-brand {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.navbar-brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-badge-bg), var(--color-primary));
  flex-shrink: 0;
}

.navbar-menu {
  display: none;
}

.navbar-menu.is-open {
  display: block;
  position: absolute;
  top: 64px;
  left: 0;
  right: 0;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-4);
  padding: var(--space-4);
}

.navbar-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: stretch;
}

.nav-link {
  display: block;
  position: relative;
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 400;
  padding: 8px 16px;
  border-radius: var(--radius-subtle);
  text-decoration: none;
  transition:
    background-color var(--motion-fast) var(--ease-in-out),
    color var(--motion-fast) var(--ease-in-out);
}

/* Animated underline: scaleX from the left on hover (Black Coffee) */
.nav-link::after {
  content: '';
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 2px;
  height: 2px;
  background: var(--color-primary);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--motion-base) var(--ease-out);
}

.nav-link:hover {
  background: rgba(57, 45, 47, 0.06);
  color: var(--color-primary);
}

.nav-link:not(.is-active):hover::after {
  transform: scaleX(1);
}

.nav-link.is-active {
  color: var(--color-primary);
  border-radius: 0;
  border-bottom: 3px solid var(--color-primary);
}

.navbar-cta {
  margin-top: var(--space-2);
}

.navbar-toggle {
  background: transparent;
  border: none;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.navbar-toggle-bars {
  position: relative;
  width: 20px;
  height: 2px;
  background: var(--color-text);
}

.navbar-toggle-bars::before,
.navbar-toggle-bars::after {
  content: '';
  position: absolute;
  left: 0;
  width: 20px;
  height: 2px;
  background: var(--color-text);
}

.navbar-toggle-bars::before {
  top: -6px;
}

.navbar-toggle-bars::after {
  top: 6px;
}

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

.footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-10);
  padding: var(--space-8) 0 var(--space-6);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
}

.footer h3 {
  font-size: 16px;
  margin-bottom: var(--space-3);
}

.footer p,
.footer li {
  font-size: 16px;
  line-height: 24px;
}

.footer ul {
  list-style: none;
}

.footer-social {
  display: flex;
  gap: var(--space-3);
}

.footer-social a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-subtle);
  color: var(--color-text);
  transition:
    background-color var(--motion-fast) var(--ease-in-out),
    color var(--motion-fast) var(--ease-in-out),
    transform var(--motion-base) var(--ease-out);
}

.footer-social a:hover {
  color: var(--color-accent-green);
  background: rgba(57, 45, 47, 0.06);
  transform: translateY(-2px);
}

.footer-bottom {
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-4);
  font-size: 14px;
  line-height: 20px;
  color: var(--color-text-muted);
}

/* Hero ==================================================================== */

.hero {
  padding: var(--space-10) 0;
  text-align: center;
}

.hero h1 {
  margin-bottom: var(--space-4);
}

.hero-tagline {
  margin-bottom: var(--space-5);
}

.hero-hours {
  display: inline-block;
  background: rgba(255, 253, 248, 0.65);
  border: 1px solid var(--color-surface);
  border-radius: var(--radius-standard);
  padding: var(--space-3) var(--space-5);
  margin-bottom: var(--space-6);
  font-size: 16px;
  line-height: 24px;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: center;
}

/* Product & content cards ================================================= */

.product-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.product-image {
  height: 160px;
  border-radius: var(--radius-standard);
  background: linear-gradient(135deg, var(--color-surface-alt), var(--color-text-muted));
}

.product-image.variant-2 {
  background: linear-gradient(135deg, var(--color-surface-alt), var(--color-accent-green));
}

.product-image.variant-3 {
  background: linear-gradient(135deg, var(--color-text-muted), var(--color-primary));
}

.product-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.badge-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-1);
}

.product-price {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
}

.values-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
  margin-top: var(--space-8);
}

/* Two-column split used on story teaser / events / donate */
.split {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
  align-items: start;
}

.blog-date {
  margin-bottom: var(--space-2);
}

.blog-card h3 {
  margin-bottom: var(--space-2);
}

/* Admin ==================================================================== */

/* Admin pages use the compact 16px reading scale */
.admin p,
.admin li,
.admin td,
.admin th {
  font-size: 16px;
  line-height: 24px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}

.admin-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
}

.alert {
  border-radius: var(--radius-standard);
  padding: 16px 20px;
  margin-bottom: var(--space-5);
  font-size: 16px;
  line-height: 24px;
}

.alert-success {
  background: rgba(95, 107, 60, 0.10);
  border: 1px solid rgba(95, 107, 60, 0.45);
  color: var(--color-accent-green);
}

.alert-error {
  background: rgba(192, 86, 33, 0.10);
  border: 1px solid rgba(192, 86, 33, 0.45);
  color: var(--color-accent-orange-text);
}

.table-wrap {
  overflow-x: auto;
  padding: 0;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.table th {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
  background: var(--color-surface-alt);
}

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

.row-inactive td {
  color: var(--color-text-muted);
}

.table-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.btn-compact {
  padding: 6px 12px;
}

.form-error {
  font-size: 14px;
  line-height: 20px;
  color: var(--color-accent-orange-text);
  font-weight: 700;
  margin-top: 4px;
}

.form-checks {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 16px;
}

.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary);
}

.form-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

/* Tablet (>= 600px) ======================================================= */

@media (min-width: 600px) {
  .container {
    padding: 0 20px;
  }

  .navbar-inner {
    padding: 0 20px;
  }

  h1 {
    font-size: 32px;
  }

  h2 {
    font-size: 26px;
  }

  .section {
    padding: var(--space-10) 0;
  }

  .grid-2,
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-5);
  }

  .hero-actions {
    flex-direction: row;
    justify-content: center;
  }

  .footer-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Desktop (>= 1024px) ===================================================== */

@media (min-width: 1024px) {
  .navbar-inner {
    padding: 0 60px;
  }

  .navbar-toggle {
    display: none;
  }

  .navbar-menu,
  .navbar-menu.is-open {
    display: block;
    position: static;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
  }

  .navbar-links {
    flex-direction: row;
    align-items: center;
    gap: var(--space-1);
  }

  .navbar-cta {
    margin-top: 0;
    margin-left: var(--space-3);
  }

  h1 {
    font-size: 36px;
    line-height: 46px;
  }

  h2 {
    font-size: 28px;
    line-height: 36px;
  }

  h3 {
    font-size: 22px;
    line-height: 28px;
  }

  .section {
    padding: var(--space-15) 0;
  }

  .hero {
    padding: var(--space-25) 0 var(--space-15);
  }

  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-6);
  }

  .split {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-10);
  }
}

/* Motion — reveal on scroll & hero entrance ===============================
   Content is visible by default; it is only hidden once a head script adds
   .js-enabled to <html>, so nothing disappears when JavaScript is off. */

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.js-enabled .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity var(--motion-slow) var(--ease-out),
    transform var(--motion-slow) var(--ease-out);
}

.js-enabled .reveal.revealed {
  opacity: 1;
  transform: none;
}

/* Staggered children: 60ms steps, capped at the 6th child */
.js-enabled .reveal-stagger > .reveal:nth-child(2) { transition-delay: 60ms; }
.js-enabled .reveal-stagger > .reveal:nth-child(3) { transition-delay: 120ms; }
.js-enabled .reveal-stagger > .reveal:nth-child(4) { transition-delay: 180ms; }
.js-enabled .reveal-stagger > .reveal:nth-child(5) { transition-delay: 240ms; }
.js-enabled .reveal-stagger > .reveal:nth-child(n+6) { transition-delay: 300ms; }

/* Hero entrance (landing page only): headline, subtext, CTA fade up in turn */
.js-enabled .hero-enter {
  animation: fade-up var(--motion-slow) var(--ease-out) backwards;
}

.js-enabled .hero-enter-2 {
  animation-delay: 100ms;
}

.js-enabled .hero-enter-3 {
  animation-delay: 200ms;
}

/* Reduced motion: kill every animation/transition, show content instantly */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0.01ms !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0.01ms !important;
  }

  .js-enabled .reveal {
    opacity: 1;
    transform: none;
  }

  .card:hover,
  .footer-social a:hover,
  .btn-icon:hover {
    transform: none;
  }
}
