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

/* --- Design Tokens & CSS Variables --- */
:root {
  /* Premium Dark Crema Theme */
  --bg-base-dark: 20s 15% 6%;      /* #120e0c */
  --bg-surface-dark: 20s 12% 10%;  /* #1c1613 */
  --bg-card-dark: 20s 10% 13%;     /* #261f1b */
  --text-primary-dark: 30s 10% 92%;/* #eae5e1 */
  --text-secondary-dark: 24s 8% 65%;/* #ab9e96 */

  /* Premium Light Cream Theme */
  --bg-base-light: 40s 20% 97%;     /* #fbfaf7 */
  --bg-surface-light: 40s 15% 94%;  /* #f3f0ea */
  --bg-card-light: 40s 15% 100%;    /* #ffffff */
  --text-primary-light: 20s 20% 12%; /* #1e1713 */
  --text-secondary-light: 20s 10% 45%;/* #7b6f67 */

  /* Accent Gold / Bronze */
  --accent-gold: 38s 60% 55%;       /* #d5a261 */
  --accent-gold-hover: 38s 70% 60%; /* #e4b476 */
  --accent-bronze: 24s 40% 40%;     /* #915a38 */
  --accent-glow: hsla(38, 60%, 55%, 0.15);

  /* System State Colors */
  --color-success: 140s 45% 45%;
  --color-info: 200s 65% 50%;
  --color-warning: 35s 75% 50%;

  /* Fonts */
  --font-display: 'Playfair Display', Georgia, serif;
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Grid & Layout */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  
  --transition-smooth: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);

  /* Default Theme Mode Set: Dark */
  --bg-base: var(--bg-base-dark);
  --bg-surface: var(--bg-surface-dark);
  --bg-card: var(--bg-card-dark);
  --text-primary: var(--text-primary-dark);
  --text-secondary: var(--text-secondary-dark);
  --border-color: hsla(24, 10%, 25%, 0.4);
  --glass-bg: hsla(20, 10%, 10%, 0.65);
  --glass-border: hsla(38, 40%, 40%, 0.15);
}

/* Light Theme Overrides */
[data-theme="light"] {
  --bg-base: var(--bg-base-light);
  --bg-surface: var(--bg-surface-light);
  --bg-card: var(--bg-card-light);
  --text-primary: var(--text-primary-light);
  --text-secondary: var(--text-secondary-light);
  --border-color: hsla(20, 10%, 80%, 0.5);
  --glass-bg: hsla(40, 15%, 100%, 0.75);
  --glass-border: hsla(38, 30%, 50%, 0.12);
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  background-color: hsl(var(--bg-base));
  color: hsl(var(--text-primary));
  font-family: var(--font-sans);
  line-height: 1.6;
  overflow-x: hidden;
  transition: var(--transition-smooth);
  background-image: 
    radial-gradient(circle at 10% 20%, hsla(38, 60%, 55%, 0.03) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, hsla(24, 40%, 40%, 0.04) 0%, transparent 40%);
  background-attachment: fixed;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 10px;
}
::-webkit-scrollbar-track {
  background: hsl(var(--bg-base));
}
::-webkit-scrollbar-thumb {
  background: hsla(38, 30%, 40%, 0.3);
  border-radius: 5px;
  border: 2px solid hsl(var(--bg-base));
}
::-webkit-scrollbar-thumb:hover {
  background: hsla(38, 50%, 50%, 0.5);
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
}

p {
  font-weight: 300;
  letter-spacing: 0.01em;
}

.text-gold {
  color: hsl(var(--accent-gold));
  background: linear-gradient(135deg, hsl(var(--accent-gold)), #f0c995);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* --- Premium Layout Utility --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
  transition: var(--transition-smooth);
}

.glass-panel:hover {
  border-color: hsla(38, 60%, 55%, 0.3);
  box-shadow: 0 12px 40px 0 rgba(212, 175, 55, 0.08);
}

/* --- Navigation Header --- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: hsla(20, 15%, 8%, 0.7);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition-smooth);
}

[data-theme="light"] .navbar {
  background: hsla(40, 20%, 97%, 0.7);
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 80px;
}

.logo {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  color: hsl(var(--text-primary));
}

.logo span {
  font-weight: 300;
  opacity: 0.8;
}

.nav-links {
  display: flex;
  gap: 32px;
  list-style: none;
}

.nav-links a {
  color: hsl(var(--text-secondary));
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: var(--transition-fast);
  position: relative;
  padding: 6px 0;
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background-color: hsl(var(--accent-gold));
  transition: var(--transition-fast);
}

.nav-links a:hover {
  color: hsl(var(--text-primary));
}

.nav-links a:hover::after {
  width: 100%;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.theme-toggle-btn, .icon-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: hsl(var(--text-primary));
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.theme-toggle-btn:hover, .icon-btn:hover {
  border-color: hsl(var(--accent-gold));
  color: hsl(var(--accent-gold));
  background: hsla(38, 60%, 55%, 0.05);
  transform: translateY(-2px);
}

/* --- Hero Section --- */
.hero {
  padding: 100px 0 60px 0;
  text-align: center;
  position: relative;
}

.hero h1 {
  font-size: 3.5rem;
  line-height: 1.2;
  margin-bottom: 24px;
}

.hero p {
  font-size: 1.2rem;
  color: hsl(var(--text-secondary));
  max-width: 600px;
  margin: 0 auto 40px auto;
}

.hero-cta-group {
  display: flex;
  justify-content: center;
  gap: 16px;
}

.btn {
  padding: 14px 28px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, hsl(var(--accent-gold)), hsl(var(--accent-bronze)));
  border: none;
  color: #120e0c;
  box-shadow: 0 4px 20px hsla(38, 60%, 55%, 0.25);
}

.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 30px hsla(38, 60%, 55%, 0.4);
}

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

.btn-secondary:hover {
  border-color: hsl(var(--accent-gold));
  color: hsl(var(--accent-gold));
  background: hsla(38, 60%, 55%, 0.05);
  transform: translateY(-3px);
}

/* --- Interactive Sections Layout --- */
.section {
  padding: 80px 0;
}

.section-title-wrap {
  text-align: center;
  margin-bottom: 50px;
}

.section-subtitle {
  color: hsl(var(--accent-gold));
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  font-weight: 700;
  margin-bottom: 12px;
  display: block;
}

.section-title {
  font-size: 2.2rem;
  margin-bottom: 16px;
}

.section-desc {
  color: hsl(var(--text-secondary));
  max-width: 600px;
  margin: 0 auto;
  font-size: 1.05rem;
}

/* Grid Layout for components */
.feature-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
}

@media (min-width: 900px) {
  .feature-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.card-content-wrapper {
  padding: 40px;
}

/* --- 1. Brewing Timer Styling --- */
.timer-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.timer-preset-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 30px;
  width: 100%;
}

.preset-chip {
  flex: 1;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: hsla(20, 10%, 15%, 0.4);
  border: 1px solid var(--border-color);
  color: hsl(var(--text-secondary));
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

.preset-chip.active {
  background: hsla(38, 60%, 55%, 0.1);
  border-color: hsl(var(--accent-gold));
  color: hsl(var(--accent-gold));
}

.timer-circle-wrap {
  position: relative;
  width: 260px;
  height: 260px;
  margin-bottom: 32px;
}

.timer-circle-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-circle-bg {
  fill: none;
  stroke: hsla(20, 10%, 20%, 0.3);
  stroke-width: 8;
}

.timer-circle-progress {
  fill: none;
  stroke: url(#gold-grad);
  stroke-width: 8;
  stroke-dasharray: 753.98; /* 2 * PI * 120 */
  stroke-dashoffset: 753.98;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.1s linear;
}

.timer-inner-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.timer-time-display {
  font-size: 3.5rem;
  font-family: var(--font-sans);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.timer-step-name {
  color: hsl(var(--accent-gold));
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 4px;
}

.timer-step-desc {
  font-size: 0.8rem;
  color: hsl(var(--text-secondary));
  margin-top: 4px;
}

.timer-guide-card {
  width: 100%;
  background: hsla(20, 10%, 15%, 0.3);
  border-radius: var(--radius-md);
  padding: 18px 24px;
  margin-bottom: 24px;
  border-left: 4px solid hsl(var(--accent-gold));
  text-align: left;
}

.timer-guide-action {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.timer-guide-sub {
  font-size: 0.9rem;
  color: hsl(var(--text-secondary));
}

.timer-controls {
  display: flex;
  gap: 16px;
}

.timer-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.timer-btn-play {
  background: hsl(var(--accent-gold));
  color: #120e0c;
  box-shadow: 0 4px 15px hsla(38, 60%, 55%, 0.3);
}

.timer-btn-play:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px hsla(38, 60%, 55%, 0.45);
}

.timer-btn-reset {
  background: transparent;
  border: 1px solid var(--border-color);
  color: hsl(var(--text-primary));
}

.timer-btn-reset:hover {
  border-color: hsl(var(--text-primary));
  background: hsla(20, 10%, 20%, 0.3);
}

/* --- 2. Grind Size Converter Styling --- */
.converter-container {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.micron-slider-wrap {
  background: hsla(20, 10%, 15%, 0.3);
  padding: 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.micron-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.micron-title {
  font-weight: 600;
  font-size: 1.1rem;
}

.micron-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: hsl(var(--accent-gold));
}

/* Custom range input */
.range-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: hsla(20, 10%, 25%, 0.5);
  outline: none;
  margin: 15px 0;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: hsl(var(--accent-gold));
  cursor: pointer;
  box-shadow: 0 0 10px hsla(38, 60%, 55%, 0.5);
  transition: var(--transition-fast);
}

.range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.grinder-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.grinder-card {
  background: hsla(20, 10%, 15%, 0.2);
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  text-align: center;
  transition: var(--transition-smooth);
}

.grinder-card:hover {
  border-color: hsla(38, 60%, 55%, 0.25);
  transform: translateY(-2px);
}

.grinder-name {
  font-size: 0.9rem;
  color: hsl(var(--text-secondary));
  margin-bottom: 8px;
}

.grinder-setting {
  font-size: 1.4rem;
  font-weight: 700;
  color: hsl(var(--text-primary));
}

.grinder-unit {
  font-size: 0.8rem;
  opacity: 0.6;
  font-weight: 400;
}

.grind-type-indicator {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  background: hsla(38, 60%, 55%, 0.08);
  border: 1px solid hsla(38, 60%, 55%, 0.15);
  text-align: center;
  font-weight: 500;
  color: hsl(var(--accent-gold));
}

/* --- 3. Tasting Wheel (Sensory Map) Styling --- */
.wheel-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
}

@media (min-width: 600px) {
  .wheel-container {
    grid-template-columns: 1.2fr 1fr;
    align-items: center;
  }
}

.chart-visual {
  display: flex;
  justify-content: center;
  position: relative;
}

.radar-chart {
  width: 100%;
  max-width: 280px;
  height: auto;
}

.radar-axis-line {
  stroke: hsla(24, 10%, 25%, 0.5);
  stroke-dasharray: 4;
}

.radar-level-line {
  fill: none;
  stroke: hsla(24, 10%, 25%, 0.3);
}

.radar-polygon-bg {
  fill: hsla(38, 60%, 55%, 0.12);
  stroke: hsl(var(--accent-gold));
  stroke-width: 2.5;
  transition: points 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.radar-text-label {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  fill: hsl(var(--text-secondary));
}

.slider-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.slider-control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slider-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

.slider-flavor-name {
  font-weight: 600;
}

.slider-flavor-val {
  color: hsl(var(--accent-gold));
  font-weight: 700;
}

.radar-slider {
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: hsla(20, 10%, 25%, 0.4);
}

.radar-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: hsl(var(--accent-gold));
  cursor: pointer;
  border: 2px solid hsl(var(--bg-card));
}

/* --- 4. Coffee Troubleshooting Styling --- */
.trouble-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.trouble-btn {
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: hsla(20, 10%, 15%, 0.2);
  color: hsl(var(--text-primary));
  font-family: var(--font-sans);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-smooth);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.trouble-btn:hover {
  border-color: hsl(var(--accent-gold));
  background: hsla(38, 60%, 55%, 0.05);
}

.trouble-btn.active {
  border-color: hsl(var(--accent-gold));
  background: hsla(38, 60%, 55%, 0.1);
  box-shadow: 0 4px 15px hsla(38, 60%, 55%, 0.1);
}

.trouble-flavor {
  font-size: 1.1rem;
  font-weight: 700;
}

.trouble-desc {
  font-size: 0.8rem;
  color: hsl(var(--text-secondary));
  font-weight: 300;
}

.trouble-solution-box {
  display: none;
  background: hsla(200, 45%, 45%, 0.05);
  border: 1px solid hsla(200, 45%, 45%, 0.2);
  border-left: 4px solid hsl(var(--color-info));
  border-radius: var(--radius-md);
  padding: 24px;
  transition: var(--transition-smooth);
  animation: fadeIn 0.4s ease-out;
}

.trouble-solution-box.active {
  display: block;
}

.solution-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: hsl(var(--text-primary));
}

.solution-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.solution-steps li {
  font-size: 0.9rem;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  color: hsl(var(--text-secondary));
}

.solution-steps li span {
  display: flex;
  align-items: center;
  justify-content: center;
  background: hsla(200, 65%, 50%, 0.15);
  color: hsl(var(--color-info));
  font-weight: 700;
  font-size: 0.75rem;
  min-width: 18px;
  height: 18px;
  border-radius: 50%;
  margin-top: 2px;
}

/* --- 5. Coffee Terroir Atlas (Origin Cards) Styling --- */
.origin-tabs {
  display: flex;
  overflow-x: auto;
  gap: 12px;
  padding-bottom: 10px;
  margin-bottom: 28px;
}

.origin-tab {
  padding: 12px 24px;
  border-radius: var(--radius-md);
  background: hsla(20, 10%, 15%, 0.3);
  border: 1px solid var(--border-color);
  color: hsl(var(--text-secondary));
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.origin-tab:hover {
  color: hsl(var(--text-primary));
  border-color: hsla(38, 60%, 55%, 0.3);
}

.origin-tab.active {
  background: hsl(var(--accent-gold));
  color: #120e0c;
  border-color: hsl(var(--accent-gold));
}

.origin-content-wrap {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
}

@media (min-width: 768px) {
  .origin-content-wrap {
    grid-template-columns: 1fr 1.2fr;
  }
}

.origin-info-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  animation: fadeIn 0.4s ease-out;
}

.origin-name-kor {
  font-size: 2.2rem;
  margin-bottom: 4px;
}

.origin-name-eng {
  font-size: 1rem;
  color: hsl(var(--accent-gold));
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 18px;
}

.origin-desc {
  font-size: 0.95rem;
  color: hsl(var(--text-secondary));
  margin-bottom: 24px;
}

.origin-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.origin-meta-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.origin-meta-label {
  font-size: 0.75rem;
  color: hsl(var(--text-secondary));
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
}

.origin-meta-value {
  font-size: 1rem;
  font-weight: 600;
}

.load-preset-btn {
  margin-top: 10px;
  align-self: flex-start;
}

/* --- Footer Styling --- */
.footer {
  border-top: 1px solid var(--border-color);
  background: hsl(var(--bg-surface));
  padding: 60px 0 40px 0;
  text-align: center;
}

.footer-logo {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.footer-copy {
  font-size: 0.85rem;
  color: hsl(var(--text-secondary));
  margin-top: 24px;
}

/* --- Keyframe Animations --- */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bounceGlow {
  0%, 100% {
    box-shadow: 0 0 10px hsla(38, 60%, 55%, 0.3);
  }
  50% {
    box-shadow: 0 0 25px hsla(38, 60%, 55%, 0.6);
  }
}

.active-pulse {
  animation: bounceGlow 2s infinite ease-in-out;
}
