/*
 * Styles for the SSR /templates pages (Thymeleaf). Ports the look of the old
 * React TemplatePage (landing.css + Tailwind) into plain CSS:
 *   dark/light alternating sections, brand palette #0f0d0a dark / #d4a853 gold /
 *   #ddd5c8 light, ink divider, preview table, HowTo step cards, CTA → /playground.
 * Served at /templates-assets/templates.css (mirrors /blog-assets/blog.css).
 */

:root {
  --tpl-dark: #0f0d0a;
  --tpl-dark-2: #1a1816;
  --tpl-gold: #d4a853;
  --tpl-gold-deep: #c4943c;
  --tpl-cream: #faf8f5;
  --tpl-light: #ddd5c8;
  --tpl-ink: #1a1a1a;
  --tpl-muted: #7a7067;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: "Swei Spring Sugar", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  color: var(--tpl-cream);
  background: var(--tpl-dark);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

img { max-width: 100%; height: auto; }

.tpl-serif {
  font-family: "Swei Spring Sugar", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, serif;
}

/* ===== Top bar (mobile-first: hamburger < 768px, inline nav ≥ 768px) ===== */
.tpl-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  background: rgba(15, 13, 10, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(212, 168, 83, 0.12);
}
.tpl-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  flex-shrink: 0;
}
.tpl-logo img { height: 26px; width: auto; }
.tpl-logo span { color: var(--tpl-gold); font-size: 1.1rem; }
/* CSS-only mobile menu: hidden checkbox toggled by the hamburger label */
.tpl-nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.tpl-burger {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; margin-right: -0.25rem;
  color: rgba(250, 248, 245, 0.85); cursor: pointer;
}
.tpl-burger svg { width: 24px; height: 24px; }
.tpl-nav { display: none; }
.tpl-nav-toggle:checked ~ .tpl-nav {
  display: flex; flex-direction: column; align-items: stretch; gap: 0.1rem;
  position: absolute; top: 100%; left: 0; right: 0;
  background: rgba(15, 13, 10, 0.97); backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(212, 168, 83, 0.12);
  padding: 0.5rem 1.25rem 0.9rem;
}
.tpl-nav a { color: rgba(250, 248, 245, 0.72); transition: color 0.2s; font-size: 0.95rem; padding: 0.6rem 0; }
.tpl-nav a:hover { color: var(--tpl-gold); }
.tpl-nav-cta {
  background: linear-gradient(135deg, var(--tpl-gold) 0%, var(--tpl-gold-deep) 100%);
  color: var(--tpl-dark) !important;
  padding: 0.5rem 1rem !important;
  border-radius: 0.5rem;
  font-weight: 700;
  text-align: center;
  margin-top: 0.4rem;
}
@media (min-width: 768px) {
  .tpl-burger { display: none; }
  .tpl-nav,
  .tpl-nav-toggle:checked ~ .tpl-nav {
    display: flex; flex-direction: row; align-items: center; gap: 1.5rem;
    position: static; background: none; backdrop-filter: none; border: none; padding: 0;
  }
  .tpl-nav a { font-size: 0.9rem; padding: 0; }
  .tpl-nav-cta { margin-top: 0; }
}
@media (max-width: 359px) { .tpl-logo span { display: none; } }

/* ===== Generic section helpers ===== */
.tpl-section { position: relative; overflow: hidden; padding: 4rem 1.25rem; }
.tpl-section-dark { background: var(--tpl-dark); }
.tpl-section-light { background: var(--tpl-light); color: var(--tpl-ink); }
.tpl-section-light2 { background: #e2dbd0; color: var(--tpl-ink); }
.tpl-section-light3 { background: #d4cabb; color: var(--tpl-ink); }
.tpl-radial::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(212, 168, 83, 0.06) 0%, transparent 70%);
  pointer-events: none;
}
.tpl-inner { position: relative; z-index: 1; max-width: 56rem; margin: 0 auto; }
.tpl-inner-narrow { max-width: 48rem; }
.tpl-inner-wide { max-width: 72rem; }

/* Ink divider */
.tpl-divider { display: flex; align-items: center; justify-content: center; }

/* ===== Hero ===== */
.tpl-hero { padding-top: 5rem; padding-bottom: 3.5rem; text-align: center; }
.tpl-hero-annot {
  display: inline-block;
  color: rgba(212, 168, 83, 0.45);
  font-size: 1rem;
  transform: rotate(-3deg);
  margin: 1.4rem 0 0.6rem;
}
.tpl-hero-icon {
  width: 4rem;
  height: 4rem;
  margin: 0.4rem auto 1.2rem;
  border-radius: 1rem;
  background: rgba(212, 168, 83, 0.1);
  color: var(--tpl-gold);
  display: flex;
  align-items: center;
  justify-content: center;
}
.tpl-hero-icon svg { width: 2rem; height: 2rem; }
.tpl-hero h1 {
  font-size: clamp(2rem, 6vw, 3.75rem);
  font-weight: 700;
  line-height: 1.15;
  margin: 0;
  color: var(--tpl-cream);
}
.tpl-hero-sub {
  margin: 1rem auto 0;
  max-width: 38rem;
  color: rgba(250, 248, 245, 0.55);
  font-size: 1.05rem;
}

/* CTA button */
.tpl-cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 2rem;
  margin-top: 2rem;
  background: linear-gradient(110deg, #d4a853 0%, #d4a853 35%, #e8c878 50%, #d4a853 65%, #c4943c 100%);
  background-size: 200% auto;
  color: var(--tpl-dark);
  font-weight: 700;
  border-radius: 0.5rem;
  box-shadow: 0 2px 8px rgba(212, 168, 83, 0.18);
  transition: box-shadow 0.3s, transform 0.3s;
  animation: tpl-shimmer 4s ease-in-out infinite;
}
.tpl-cta-btn:hover { box-shadow: 0 4px 24px rgba(212, 168, 83, 0.4); transform: translateY(-2px); }
.tpl-cta-btn svg { width: 1rem; height: 1rem; }
@keyframes tpl-shimmer {
  0% { background-position: 200% center; }
  100% { background-position: -200% center; }
}

/* ===== Intro / TLDR card ===== */
.tpl-intro { padding-top: 0; padding-bottom: 3.5rem; }
.tpl-intro-card {
  border: 1px solid rgba(212, 168, 83, 0.15);
  background: rgba(26, 24, 22, 0.6);
  border-radius: 1rem;
  padding: 2rem 1.75rem;
}
.tpl-intro-card p { margin: 0; color: rgba(250, 248, 245, 0.78); font-size: 1.05rem; line-height: 1.9; }

/* ===== Section heading ===== */
.tpl-head { text-align: center; margin-bottom: 2.5rem; }
.tpl-head h2 {
  margin: 1.4rem 0 0;
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  font-weight: 700;
}
.tpl-head .tpl-accent { color: var(--tpl-gold-deep); }
.tpl-section-dark .tpl-head h2 { color: var(--tpl-cream); }
.tpl-section-dark .tpl-head .tpl-accent { color: var(--tpl-gold); }
.tpl-head p { margin: 0.75rem 0 0; color: var(--tpl-muted); font-size: 0.95rem; }

/* ===== Preview table ===== */
.tpl-table-wrap {
  overflow-x: auto;
  border-radius: 0.75rem;
  border: 1px solid rgba(196, 184, 154, 0.5);
  background: rgba(250, 248, 245, 0.7);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.tpl-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 0.95rem; }
.tpl-table thead tr { border-bottom: 1px solid rgba(196, 184, 154, 0.6); background: #e7dfd2; }
.tpl-table th[scope="col"] { padding: 0.75rem 1rem; font-weight: 700; color: var(--tpl-ink); }
.tpl-table th.tpl-col-field { width: 33%; min-width: 7rem; white-space: nowrap; }
.tpl-table tbody tr { border-bottom: 1px solid rgba(196, 184, 154, 0.3); }
.tpl-table tbody tr:last-child { border-bottom: 0; }
.tpl-table tbody tr.tpl-odd { background: rgba(243, 237, 226, 0.5); }
.tpl-table th[scope="row"] {
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: #5a5048;
  vertical-align: top;
  white-space: nowrap;
}
.tpl-table td { padding: 0.75rem 1rem; color: #3a342e; }

/* ===== Usage guide ===== */
.tpl-guide p {
  color: rgba(250, 248, 245, 0.65);
  font-size: 1.05rem;
  margin: 0 0 1.25rem;
}

/* ===== HowTo steps ===== */
.tpl-steps-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}
.tpl-step-card {
  position: relative;
  border: 1px solid rgba(196, 184, 154, 0.4);
  background: rgba(250, 248, 245, 0.7);
  border-radius: 1rem;
  padding: 1.75rem 1.5rem 1.5rem;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.tpl-step-card:hover { border-color: rgba(196, 148, 60, 0.5); box-shadow: 0 10px 30px rgba(120, 100, 60, 0.1); }
.tpl-step-badge {
  position: absolute;
  top: -0.75rem;
  left: 1.5rem;
  background: var(--tpl-gold-deep);
  color: var(--tpl-cream);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.75rem;
  border-radius: 999px;
}
.tpl-step-card h3 { margin: 0.5rem 0 0.5rem; font-size: 1.1rem; font-weight: 700; color: var(--tpl-ink); }
.tpl-step-card p { margin: 0; font-size: 0.9rem; color: var(--tpl-muted); }

/* ===== Related templates ===== */
.tpl-related-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}
.tpl-related-card {
  display: block;
  background: linear-gradient(155deg, rgba(247, 242, 230, 0.95) 0%, rgba(252, 250, 245, 0.98) 40%, rgba(245, 239, 226, 0.95) 100%);
  border: 1px solid rgba(180, 155, 110, 0.18);
  border-radius: 0.75rem;
  padding: 1.75rem;
  transition: transform 0.3s, border-color 0.3s, box-shadow 0.3s;
}
.tpl-related-card:hover {
  transform: translateY(-4px);
  border-color: rgba(212, 168, 83, 0.3);
  box-shadow: 0 20px 50px rgba(120, 100, 60, 0.1);
}
.tpl-related-card h3 { margin: 0 0 0.5rem; font-size: 1.1rem; font-weight: 700; color: var(--tpl-ink); transition: color 0.2s; }
.tpl-related-card:hover h3 { color: var(--tpl-gold-deep); }
.tpl-related-card p { margin: 0; font-size: 0.9rem; color: var(--tpl-muted); }
.tpl-related-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--tpl-gold-deep);
}
.tpl-related-link svg { width: 0.85rem; height: 0.85rem; }

/* ===== Index page card grid ===== */
.tpl-index-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

/* ===== Final CTA ===== */
.tpl-final { text-align: center; padding: 5rem 1.25rem; }
.tpl-final .tpl-annot {
  display: block;
  color: rgba(212, 168, 83, 0.35);
  font-size: 1.25rem;
  margin: 2rem 0 0.75rem;
}
.tpl-final h2 {
  font-size: clamp(1.75rem, 5vw, 3rem);
  font-weight: 700;
  margin: 0;
  color: var(--tpl-cream);
}
.tpl-final h2 .tpl-accent { color: var(--tpl-gold); }
.tpl-final-sub { margin: 1rem auto 0; max-width: 32rem; color: rgba(250, 248, 245, 0.5); }
.tpl-final-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 2.5rem;
}
.tpl-link-underline {
  color: rgba(250, 248, 245, 0.5);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: rgba(212, 168, 83, 0.3);
  font-size: 0.9rem;
  transition: color 0.2s;
}
.tpl-link-underline:hover { color: rgba(250, 248, 245, 0.8); }

/* ===== Related features (倒流到 /features/* 功能頁) ===== */
.tpl-feature-intro { text-align: center; color: rgba(250, 248, 245, 0.55); margin: 0 auto 1.5rem; max-width: 32rem; font-size: 0.95rem; }
.tpl-feature-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; }
.tpl-feature-pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.6rem 1.1rem; border-radius: 999px;
  border: 1px solid rgba(212, 168, 83, 0.35);
  color: var(--tpl-gold); font-weight: 600; font-size: 0.9rem;
  transition: background 0.2s, border-color 0.2s;
}
.tpl-feature-pill:hover { background: rgba(212, 168, 83, 0.12); border-color: rgba(212, 168, 83, 0.6); }
.tpl-feature-pill svg { width: 0.9rem; height: 0.9rem; }

/* ===== Footer ===== */
.tpl-footer { background: #0a0908; border-top: 1px solid rgba(212, 168, 83, 0.1); padding: 3rem 1.25rem; }
.tpl-footer-inner { max-width: 72rem; margin: 0 auto; }
.tpl-footer-end { text-align: center; color: rgba(212, 168, 83, 0.25); font-size: 1.1rem; margin-bottom: 2rem; }
.tpl-footer-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.tpl-footer-logo { display: inline-flex; align-items: center; gap: 0.6rem; }
.tpl-footer-logo img { height: 24px; width: auto; }
.tpl-footer-logo span { color: rgba(212, 168, 83, 0.5); font-size: 0.9rem; }
.tpl-footer-meta { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }
.tpl-footer-links { display: flex; gap: 1rem; font-size: 0.75rem; }
.tpl-footer-links a { color: rgba(250, 248, 245, 0.3); transition: color 0.2s; }
.tpl-footer-links a:hover { color: rgba(250, 248, 245, 0.5); }
.tpl-footer-meta p { margin: 0; font-size: 0.75rem; color: rgba(250, 248, 245, 0.3); }
.tpl-footer-meta a { color: rgba(212, 168, 83, 0.5); }

/* ===== Responsive ===== */
@media (min-width: 640px) {
  .tpl-steps-grid { grid-template-columns: repeat(2, 1fr); }
  .tpl-related-grid { grid-template-columns: repeat(3, 1fr); }
  .tpl-index-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .tpl-section { padding: 6rem 1.5rem; }
  .tpl-steps-grid { grid-template-columns: repeat(4, 1fr); }
  .tpl-index-grid { grid-template-columns: repeat(3, 1fr); }
}
