/* === CSS Custom Properties === */
:root {
  --color-bg: #F5F3EE;
  --color-bg-alt: #ECEAE4;
  --color-text: #3B1E1A;
  --color-text-light: #6B4842;
  --color-accent: #3B1E1A;
  --color-accent-hover: #5A3530;
  --color-timer-bg: #3B1E1A;
  --color-timer-text: #F5F3EE;
  --color-phase-bloom: #3B1E1A;
  --color-phase-pour: #3B1E1A;
  --color-phase-wait: #6B4842;
  --color-border: rgba(59, 30, 26, 0.15);
  --color-shadow: rgba(59, 30, 26, 0.08);

  --font-display: 'Space Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-hand: 'Fraunces', ui-serif, Georgia, serif;
  --font-body: 'Inter', ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --font-quote: 'Cormorant Garamond', 'Georgia', serif;


  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;

  --transition: 0.2s ease;
}

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

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

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

/* === Ad Slots === */
.ad-slot {
  width: 100%;
  max-width: 728px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-slot--banner {
  min-height: 0;
  margin-top: 12px;
}

.ad-slot--rectangle {
  min-height: 0;
  margin: 24px auto;
}

/* === Main Container === */
.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px;
  align-items: center;
  align-content: center;
  flex: 1;
  min-height: calc(100vh - 80px);
}

/* === Illustration Area === */
.illustration-area {
  display: flex;
  align-items: center;
  justify-content: center;
}

.coffee-illustration {
  width: 100%;
  max-width: 340px;
}

.coffee-illustration svg {
  width: 100%;
  height: auto;
}

/* === Timer Area === */
.timer-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

/* === Phase Display === */
.phase-display {
  text-align: center;
}

.phase-name{
  font-family: var(--font-hand);
  font-size: 2.8rem;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: 0.06em;
  text-transform: lowercase;
  transition: color 0.4s ease, transform 0.3s ease;
}

/* Phase-specific colors */
body[data-phase="bloom"] .timer-display {
  background: #4A2520;
}

body[data-phase="pour"] .timer-display {
  background: #3B1E1A;
}

body[data-phase="wait"] .timer-display {
  background: #2E1512;
}

body[data-phase="bloom"] .phase-name { color: var(--color-text); }
body[data-phase="pour"]  .phase-name { color: var(--color-text); }
body[data-phase="wait"]  .phase-name { color: var(--color-text-light); }

/* === Timer Display === */
.timer-display {
  background: var(--color-timer-bg);
  border-radius: 16px;
  padding: 22px 36px;
  min-width: 280px;
  box-shadow:
    0 10px 30px var(--color-shadow),
    inset 0 1px 0 rgba(255,255,255,0.05);
  transition: background 0.6s ease;
}

.timer-digits {
  font-family: var(--font-display);
  font-size: 4.0rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--color-timer-text);
  text-shadow: 0 0 20px rgba(245, 243, 238, 0.15);
  display: flex;
  justify-content: center;
  align-items: center;
  line-height: 1;
}

.timer-digit {
  display: inline-block;
  width: 0.75em;
  text-align: center;
}

.timer-colon {
  display: inline-block;
  width: 0.4em;
  text-align: center;
}

/* === Controls === */
.controls {
  display: flex;
  gap: 12px;
}

.btn {
  font-family: var(--font-hand);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 10px 22px;
  min-width: 88px;
  letter-spacing: 0.02em;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), opacity var(--transition);
  outline: none;
}

.btn:focus-visible {
  box-shadow: 0 0 0 3px var(--color-accent);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn--start {
  background: var(--color-accent);
  color: #fff;
}

.btn--start:hover:not(:disabled) {
  background: var(--color-accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 30, 26, 0.2);
}

.btn--pause {
  background: var(--color-bg-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn--pause:hover:not(:disabled) {
  background: #E2DFD8;
  transform: translateY(-1px);
}

.btn--stop {
  background: var(--color-bg-alt);
  color: var(--color-text-light);
  border: 1px solid var(--color-border);
}

.btn--stop:hover:not(:disabled) {
  background: #E2DFD8;
  transform: translateY(-1px);
}

/* === Settings === */
.settings {
  width: 100%;
  max-width: 360px;
  margin-top: 8px;
}

.settings-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--color-text-light);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px 0;
  margin-bottom: 4px;
  transition: color var(--transition);
}

.settings-toggle:hover {
  color: var(--color-text);
}

.settings-chevron {
  transition: transform 0.25s ease;
}

.settings-toggle[aria-expanded="true"] .settings-chevron {
  transform: rotate(180deg);
}

.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.25s ease;
}

.settings-grid.open {
  max-height: 300px;
  opacity: 1;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.setting-label {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-text);
  letter-spacing: 0.02em;
  min-width: 64px;
  text-transform: lowercase;
}

.setting-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #44231E;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
}

.setting-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(245, 243, 238, 0.15);
  color: var(--color-timer-text);
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
  line-height: 1;
}

.setting-btn:hover:not(:disabled) {
  background: rgba(245, 243, 238, 0.3);
}

.setting-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.setting-input {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--color-timer-text);
  background: transparent;
  border: none;
  text-align: center;
  width: 56px;
  outline: none;
  -moz-appearance: textfield;
}

.setting-input::-webkit-outer-spin-button,
.setting-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.setting-input:disabled {
  opacity: 0.5;
}

.setting-unit {
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: rgba(245, 243, 238, 0.5);
  letter-spacing: 0.04em;
}

.bmc-wrap{
  width: 100%;
  display: flex;
  justify-content: center;
  margin: 14px 0 0;
}

.bmc-link{
  display: inline-flex;
}

.bmc-img{
  display: block;
}


.coffee-button {
  width: 100%;
  margin-top: 32px;
  display: flex;
  justify-content: center;
}

.coffee-button a {
  display: inline-flex;
  justify-content: center;
}

.coffee-button img {
  display: block;
}

.below-coffee{
  display: block;
  margin: 20px auto 0;
  max-width: 360px;
  width: 100%;
  opacity: 0.9;
  animation: fadeIn 1.2s ease forwards;
}

/* === Music Player === */
.music-player {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.music-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.music-lucky-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 2px 12px var(--color-shadow);
  letter-spacing: 0.02em;
}

.music-lucky-btn:hover {
  background: var(--color-accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(59, 30, 26, 0.2);
}

.music-lucky-btn svg {
  flex-shrink: 0;
}

.music-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--color-timer-bg);
  color: var(--color-timer-text);
  border: none;
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-family: var(--font-body);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 2px 12px var(--color-shadow);
}

.music-toggle:hover {
  background: #5A3530;
  transform: translateY(-1px);
}

.music-player-embed {
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 4px 20px var(--color-shadow);
}

/* === Quotes Section === */
.quotes-section {
  width: min(92vw, 560px);
  max-width: 600px;
  margin: 0 auto;
  padding: 24px 0px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.quote-text{
  font-family: var(--font-quote);
  font-size: 1.2rem;
  font-style: italic;
  color: var(--color-text);
  opacity: 0.8;
  line-height: 1.8;
  max-width: 560px;
  margin: 0 auto;
}

.quote-text a{
  color: var(--color-text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.quote-text a:hover{
  color: var(--color-accent-hover);
}

.quote-text img {
  display: block;
  margin: 0 auto;
  max-width: 220px;
  height: auto;
}
/* === Footer === */
.footer {
  text-align: center;
  padding: 16px;
  font-size: 0.8rem;
  color: var(--color-text-light);
  opacity: 0.6;
}

/* === SVG Animations === */
@keyframes breathe {
  0%, 100% {
    transform: scale(1) translateY(0);
  }
  50% {
    transform: scale(1.008) translateY(-1px);
  }
}

@keyframes fadeIn{
  from { opacity:0; transform: translateY(6px); }
  to { opacity:0.9; transform: translateY(0); }
}

@keyframes gentleSway {
  0%, 100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(0.3deg);
  }
  75% {
    transform: rotate(-0.3deg);
  }
}

.illustration-body {
  animation: breathe 5s ease-in-out infinite;
  transform-origin: center center;
}

.coffee-illustration svg {
  animation: gentleSway 8s ease-in-out infinite;
  transform-origin: center center;
}

/* === Drip Animation (pour phase) === */
@keyframes dripFall {
  0% {
    transform: translateY(0);
    opacity: 0;
  }
  10% {
    opacity: 0.6;
  }
  80% {
    opacity: 0.3;
  }
  100% {
    transform: translateY(35px);
    opacity: 0;
  }
}

.drip-1 {
  animation: dripFall 2.4s ease-in infinite;
}

.drip-2 {
  animation: dripFall 2.4s ease-in 0.8s infinite;
}

.drip-3 {
  animation: dripFall 2.4s ease-in 1.6s infinite;
}

/* === Phase transition animation === */
@keyframes phaseIn {
  0% {
    transform: translateY(-8px);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.phase-name.transitioning {
  animation: phaseIn 0.4s ease-out;
}



/* === Responsive === */
@media (max-width: 768px) {
  .container {
    grid-template-columns: 1fr;
    gap: 32px;
    padding: 24px 20px 40px;
  }

  .illustration-area {
    order: 2;
  }

  .timer-area {
    order: 1;
  }

  .coffee-illustration {
    max-width: 280px;
  }

  .phase-name {
    font-size: 2.2rem;
  }

  .timer-digits {
    font-size: 3.2rem;
  }

  .timer-display {
    padding: 20px 36px;
    min-width: 260px;
  }

  .btn,
  .setting-label,
  .settings-toggle {
    font-family: var(--font-body);
  }

  .quotes-section {
    gap: 4px;
  }

  .quote-text {
    font-size: 1.05rem;
    line-height: 1.6;
  }

  .btn {
    padding: 10px 24px;
    font-size: 0.9rem;
  }

  .quotes-section {
    padding: 24px 20px 40px;
  }

  .music-player {
    bottom: calc(12px + env(safe-area-inset-bottom));
    right: 12px;
  }
}

@media (max-width: 400px) {
  .timer-digits {
    font-size: 2.6rem;
  }

  .timer-display {
    padding: 16px 28px;
  }

  .controls {
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (max-width: 768px) {
  .quotes-section {
    padding-bottom: 90px; /* floating UI 피하기 */
  }
}
