/* =========================================================
   TOKENS
   ========================================================= */
:root {
  --bg: #EEF2E4;
  --bg-card: #F7F9F0;
  --ink: #2B2A22;
  --ink-soft: #5C5A4C;
  --line: #C9CEB8;

  --moss: #4F7247;
  --moss-deep: #37512F;
  --sky-day-top: #7FB6D9;
  --sky-day-bottom: #DCEEF4;
  --sky-eve-top: #D98B5F;
  --sky-eve-bottom: #F4CFA4;
  --sky-night-top: #1B2A4A;
  --sky-night-bottom: #3B4A70;
  --gold: #D9A441;
  --berry: #A6474B;
  --wood: #9C6B44;
  --wood-dark: #6E4A2E;
  --wood-light: #C79A6C;

  --display: "Fraunces", Georgia, serif;
  --body: "Karla", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;

  --radius: 14px;
  --shadow-soft: 0 10px 30px -14px rgba(43, 42, 34, 0.35);
}

/* current sky state, swapped by JS based on time of day */
body.time-day     { --sky-top: var(--sky-day-top);   --sky-bottom: var(--sky-day-bottom); }
body.time-dusk    { --sky-top: var(--sky-eve-top);   --sky-bottom: var(--sky-eve-bottom); }
body.time-night   { --sky-top: var(--sky-night-top); --sky-bottom: var(--sky-night-bottom); }

/* =========================================================
   BASE
   ========================================================= */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 15% 8%, rgba(79,114,71,0.06), transparent 45%),
    radial-gradient(circle at 85% 30%, rgba(217,164,65,0.07), transparent 40%);
  color: var(--ink);
  font-family: var(--body);
  line-height: 1.55;
  position: relative;
  overflow-x: hidden;
}

/* subtle paper grain, purely atmospheric */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.05;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

h1, h2 { font-family: var(--display); color: var(--moss-deep); margin: 0; }

a { color: var(--moss-deep); }
a:hover { color: var(--berry); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

/* =========================================================
   DECORATIVE VINE
   ========================================================= */
.vine {
  position: absolute;
  top: 0;
  width: 60px;
  height: 900px;
  z-index: 0;
  opacity: 0.55;
}
.vine-left { left: -10px; }
@media (max-width: 780px) { .vine { display: none; } }

/* =========================================================
   HEADER
   ========================================================= */
.site-head {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  padding: 4.5rem 1.5rem 2.5rem;
  text-align: center;
}
.eyebrow {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 0.75rem;
}
.site-title {
  font-size: clamp(2.6rem, 6vw, 4.2rem);
  font-weight: 600;
  font-style: italic;
  letter-spacing: -0.01em;
}
.site-sub {
  max-width: 46ch;
  margin: 1.1rem auto 0;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

/* =========================================================
   ROOM LAYOUT (shared by both sections)
   ========================================================= */
main {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1.5rem 2rem;
}

.room {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 3rem;
  align-items: center;
  padding: 3rem 0;
}
.room-reverse { grid-template-columns: 0.95fr 1.05fr; }
.room-reverse .room-copy { order: 2; }
.room-reverse .door-scene { order: 1; }

.room + .room {
  border-top: 1px solid var(--line);
}

.room-copy h2 {
  font-size: 2.1rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
}
.room-copy p {
  color: var(--ink-soft);
  max-width: 46ch;
}
.hint {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
  opacity: 0.85;
  margin-top: 0.85rem;
}

@media (max-width: 900px) {
  .room, .room-reverse { grid-template-columns: 1fr; }
  .room-reverse .room-copy, .room-reverse .door-scene { order: initial; }
}

/* =========================================================
   FORM + BUTTONS
   ========================================================= */
.weather-form {
  display: flex;
  gap: 0.6rem;
  margin: 1.4rem 0 0.5rem;
  flex-wrap: wrap;
}
#city-input {
  flex: 1 1 220px;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--bg-card);
  font-family: var(--body);
  font-size: 1rem;
  color: var(--ink);
}
#city-input::placeholder { color: #8b8a78; }
#city-input:focus { border-color: var(--moss); }

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  font-family: var(--body);
  font-weight: 700;
  font-size: 0.98rem;
  padding: 0.78rem 1.4rem;
  background: var(--moss);
  color: #F7F9F0;
  transition: transform 0.15s ease, background 0.2s ease;
  white-space: nowrap;
}
button:hover { background: var(--moss-deep); transform: translateY(-1px); }
button:active { transform: translateY(0); }
button:disabled { opacity: 0.6; cursor: progress; transform: none; }

#cat-button { background: var(--berry); }
#cat-button:hover { background: #7f3236; }

#kitchen-button { background: var(--gold); color: #3A2A0E; }
#kitchen-button:hover { background: #C4901E; }

.secondary-button {
  background: transparent;
  color: var(--moss-deep);
  box-shadow: inset 0 0 0 1.5px var(--line);
  margin-top: 0.6rem;
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
}
.secondary-button:hover { background: rgba(79,114,71,0.08); color: var(--moss-deep); }

.status {
  min-height: 1.4em;
  font-size: 0.92rem;
  color: var(--ink-soft);
  margin-top: 0.6rem;
}
.status.is-error { color: var(--berry); font-weight: 600; }

/* =========================================================
   WINDOW SCENE (signature element, section 1)
   ========================================================= */
.window-scene { display: flex; justify-content: center; }

.window-frame {
  position: relative;
  width: 100%;
  max-width: 340px;
  aspect-ratio: 4 / 5;
  padding: 14px;
  background: linear-gradient(160deg, var(--wood-light), var(--wood) 45%, var(--wood-dark));
  border-radius: 18px;
  box-shadow: var(--shadow-soft);
}

.sky {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--sky-top, var(--sky-day-top)) 0%, var(--sky-bottom, var(--sky-day-bottom)) 100%);
  transition: background 1.2s ease;
}
/* muntin bars, like real window panes */
.sky::before, .sky::after {
  content: "";
  position: absolute;
  background: rgba(255,255,255,0.28);
  z-index: 3;
}
.sky::before { left: 50%; top: 0; bottom: 0; width: 4px; transform: translateX(-50%); }
.sky::after  { top: 50%; left: 0; right: 0; height: 4px; transform: translateY(-50%); }

.sun-moon {
  position: absolute;
  top: 14%;
  right: 16%;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFF4D6, var(--gold));
  box-shadow: 0 0 26px 6px rgba(217,164,65,0.55);
  transition: background 1s ease, box-shadow 1s ease;
}
body.time-night .sun-moon {
  background: radial-gradient(circle at 35% 30%, #F4F6FF, #C9D2EC);
  box-shadow: 0 0 18px 4px rgba(201,210,236,0.5);
}

.cloud {
  position: absolute;
  background: rgba(255,255,255,0.85);
  border-radius: 40px;
  filter: blur(0.5px);
  animation: drift 40s linear infinite;
}
.cloud::before, .cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  border-radius: 50%;
}
.cloud-a { width: 70px; height: 22px; top: 20%; left: -20%; animation-duration: 34s; }
.cloud-a::before { width: 34px; height: 34px; top: -16px; left: 8px; }
.cloud-a::after  { width: 26px; height: 26px; top: -10px; left: 34px; }
.cloud-b { width: 54px; height: 18px; top: 45%; left: -30%; animation-duration: 46s; animation-delay: -12s; }
.cloud-b::before { width: 26px; height: 26px; top: -12px; left: 6px; }
.cloud-b::after  { width: 20px; height: 20px; top: -8px; left: 26px; }
.cloud-c { width: 40px; height: 14px; top: 68%; left: -25%; animation-duration: 30s; animation-delay: -6s; }
.cloud-c::before { width: 20px; height: 20px; top: -9px; left: 4px; }

@keyframes drift {
  from { transform: translateX(0); }
  to { transform: translateX(420%); }
}

.sill {
  position: absolute;
  left: -14px; right: -14px; bottom: -8px;
  height: 18px;
  background: linear-gradient(180deg, var(--wood-light), var(--wood-dark));
  border-radius: 0 0 10px 10px;
}

/* =========================================================
   WEATHER-DRIVEN WINDOW STATES
   Set on <body> by script.js once a forecast comes back, based
   on the condition at the last place that was searched.
   ========================================================= */
.sun-moon { transition: background 1s ease, box-shadow 1s ease, opacity 0.8s ease; }
.cloud { transition: opacity 0.8s ease, filter 0.8s ease; }

body.weather-overcast .sun-moon,
body.weather-rain .sun-moon,
body.weather-snow .sun-moon,
body.weather-storm .sun-moon,
body.weather-fog .sun-moon { opacity: 0.12; }

body.weather-clear .cloud { opacity: 0.3; }
body.weather-cloudy .cloud { opacity: 0.95; }
body.weather-overcast .cloud,
body.weather-rain .cloud,
body.weather-storm .cloud,
body.weather-snow .cloud { opacity: 1; filter: brightness(0.9); }

body.weather-wind .cloud-a { animation-duration: 15s; }
body.weather-wind .cloud-b { animation-duration: 19s; }
body.weather-wind .cloud-c { animation-duration: 13s; }

/* sky tint per condition — sits after the time-of-day rules, so it wins */
body.weather-cloudy    { --sky-top: #9FB2BC; --sky-bottom: #DCE4E6; }
body.weather-overcast  { --sky-top: #8C97A0; --sky-bottom: #C7CFD2; }
body.weather-rain      { --sky-top: #64809C; --sky-bottom: #A6BFCF; }
body.weather-storm     { --sky-top: #48505E; --sky-bottom: #78838F; }
body.weather-snow      { --sky-top: #B8C7D6; --sky-bottom: #EAF0F5; }
body.weather-fog       { --sky-top: #C7D0CE; --sky-bottom: #E7ECE9; }

/* rain / snow */
.precip {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}
.precip .drop {
  position: absolute;
  top: -10%;
  width: 2px;
  height: 14px;
  background: rgba(255,255,255,0.65);
  border-radius: 1px;
  animation-name: fall-rain;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
.precip .flake {
  position: absolute;
  top: -10%;
  background: #ffffff;
  border-radius: 50%;
  opacity: 0.9;
  animation-name: fall-snow;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
@keyframes fall-rain {
  from { transform: translateY(-20%); }
  to   { transform: translateY(430%); }
}
@keyframes fall-snow {
  0%   { transform: translate(0, -20%); }
  50%  { transform: translate(8px, 200%); }
  100% { transform: translate(-6px, 430%); }
}

/* fog */
.fog-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0;
  transition: opacity 1s ease;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.6) 55%, rgba(255,255,255,0.82));
}
body.weather-fog .fog-layer { opacity: 1; }

/* storm flashes */
.lightning {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
}
.lightning.flash { animation: lightning-flash 0.45s ease; }
@keyframes lightning-flash {
  0%   { opacity: 0; }
  10%  { opacity: 0.9; }
  22%  { opacity: 0.05; }
  32%  { opacity: 0.55; }
  100% { opacity: 0; }
}

/* =========================================================
   WEATHER RESULT CARDS
   ========================================================= */
.weather-result { margin-top: 1.6rem; }

.current-card {
  display: flex;
  gap: 1rem;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
}
.current-place {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 0.15rem;
}
.current-period { margin: 0; font-weight: 700; }
.current-temp {
  font-family: var(--mono);
  font-size: 1.6rem;
  margin: 0.15rem 0;
  color: var(--moss-deep);
}
.current-short { margin: 0; color: var(--ink-soft); }

.forecast-row {
  display: flex;
  gap: 0.7rem;
  overflow-x: auto;
  margin-top: 0.9rem;
  padding-bottom: 0.4rem;
}
.forecast-card {
  flex: 0 0 auto;
  min-width: 108px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.6rem;
  text-align: center;
}
.forecast-card .fc-name {
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  margin: 0 0 0.35rem;
}
.forecast-card img { width: 40px; height: 40px; }
.forecast-card .fc-temp {
  font-family: var(--mono);
  font-weight: 500;
  margin: 0.3rem 0 0.1rem;
}
.forecast-card .fc-short {
  font-size: 0.76rem;
  color: var(--ink-soft);
  margin: 0;
}

/* =========================================================
   DOOR SCENE (signature element, section 2)
   ========================================================= */
.door-scene {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.door-frame {
  position: relative;
  width: 100%;
  max-width: 300px;
  aspect-ratio: 3 / 4.4;
  background: linear-gradient(160deg, var(--wood-light), var(--wood) 45%, var(--wood-dark));
  border-radius: 16px 16px 6px 6px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  padding: 12px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.door-frame:hover { transform: translateY(-2px); box-shadow: 0 14px 34px -14px rgba(43, 42, 34, 0.45); }
.door-frame:active { transform: translateY(0); }

.door-tip {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--ink-soft);
  opacity: 0.8;
  margin: 0;
}

.cat-window {
  position: absolute;
  inset: 12px;
  border-radius: 10px;
  background: #2E2A22;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.cat-placeholder {
  font-family: var(--display);
  font-style: italic;
  font-size: 3rem;
  color: rgba(247,249,240,0.35);
  margin: 0;
}
#cat-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.door-leaf {
  position: absolute;
  top: 12px; bottom: 12px;
  width: calc(50% - 12px);
  background: linear-gradient(160deg, var(--wood-light), var(--wood) 55%, var(--wood-dark));
  z-index: 2;
  transition: transform 0.85s cubic-bezier(.4,0,.2,1);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,0.08);
}
.door-leaf::before {
  content: "";
  position: absolute;
  inset: 14px;
  border: 2px solid rgba(0,0,0,0.12);
  border-radius: 4px;
}
.door-left  { left: 12px; transform-origin: left center; }
.door-right { right: 12px; transform-origin: right center; }

/* opened state, toggled by JS */
.door-scene.is-open .door-left  { transform: perspective(600px) rotateY(-108deg); }
.door-scene.is-open .door-right { transform: perspective(600px) rotateY(108deg); }

/* =========================================================
   PANTRY SCENE (signature element, section 3)
   ========================================================= */
.pantry-scene { display: flex; justify-content: center; }

.pantry-frame {
  position: relative;
  width: 100%;
  max-width: 300px;
  aspect-ratio: 3 / 4.4;
  background: linear-gradient(160deg, #F2EFE2, #E4DEC9 55%, #D3CAAA);
  border-radius: 10px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  padding: 10px;
}

.pantry-interior {
  position: absolute;
  inset: 10px;
  border-radius: 6px;
  background: linear-gradient(180deg, #3A3226, #241F18);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
}

.pantry-pot {
  width: 42%;
  aspect-ratio: 2 / 1;
  margin-bottom: 14%;
  background: linear-gradient(160deg, #B0563F, #7C3A28);
  border-radius: 6px 6px 40% 40% / 6px 6px 60% 60%;
  box-shadow: 0 6px 14px rgba(0,0,0,0.35);
  position: relative;
}
.pantry-pot::before, .pantry-pot::after {
  content: "";
  position: absolute;
  top: 30%;
  width: 14%;
  height: 10%;
  border: 3px solid #7C3A28;
  border-radius: 3px;
}
.pantry-pot::before { left: -10%; }
.pantry-pot::after { right: -10%; }

.pantry-steam {
  position: absolute;
  bottom: 38%;
  width: 6px;
  height: 26px;
  border-radius: 3px;
  background: rgba(255,255,255,0.55);
  opacity: 0;
  animation: steam-rise 2.6s ease-in infinite;
}
.pantry-steam-a { left: 44%; animation-delay: 0s; }
.pantry-steam-b { left: 54%; animation-delay: 1s; }
@keyframes steam-rise {
  0%   { opacity: 0; transform: translateY(0) scaleX(1); }
  30%  { opacity: 0.7; }
  100% { opacity: 0; transform: translateY(-34px) scaleX(1.6); }
}

.pantry-leaf {
  position: absolute;
  top: 10px; bottom: 10px;
  width: calc(50% - 10px);
  background: linear-gradient(160deg, #F2EFE2, #E4DEC9 55%, #D3CAAA);
  z-index: 2;
  transition: transform 0.85s cubic-bezier(.4,0,.2,1);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,0.06);
}
.pantry-leaf::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 2px solid rgba(0,0,0,0.08);
  border-radius: 4px;
}
.pantry-knob {
  position: absolute;
  top: 50%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--wood-dark);
  transform: translateY(-50%);
}
.pantry-left  { left: 10px; transform-origin: left center; }
.pantry-left .pantry-knob { right: 14px; }
.pantry-right { right: 10px; transform-origin: right center; }
.pantry-right .pantry-knob { left: 14px; }

.pantry-scene.is-open .pantry-left  { transform: perspective(600px) rotateY(-108deg); }
.pantry-scene.is-open .pantry-right { transform: perspective(600px) rotateY(108deg); }

/* =========================================================
   RECIPE CARD
   ========================================================= */
.recipe-result { margin-top: 1.4rem; }

.recipe-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
}

.recipe-badges { margin: 0 0 0.5rem; }
.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--moss-deep);
  background: rgba(79,114,71,0.12);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  margin: 0 0.3rem 0.3rem 0;
}

.recipe-header {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.6rem;
}
.recipe-icon {
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  border-radius: 12px;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--line);
  padding: 8px;
}
.recipe-icon svg { width: 100%; height: 100%; display: block; }
.recipe-header-text { flex: 1 1 auto; min-width: 0; }

.recipe-name {
  font-size: 1.4rem;
  margin: 0 0 0.35rem;
}
.recipe-description {
  color: var(--ink-soft);
  margin: 0;
}
.recipe-meta {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin: 0 0 0.9rem;
}

.recipe-actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0 0 1.1rem;
  flex-wrap: wrap;
}
.recipe-actions .secondary-button { margin-top: 0; padding: 0.5rem 1rem; font-size: 0.85rem; }
.share-feedback {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--moss-deep);
  min-height: 1.2em;
}

.recipe-columns {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 1.4rem;
}
@media (max-width: 560px) {
  .recipe-columns { grid-template-columns: 1fr; }
}

.recipe-subhead {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 0.5rem;
}

.recipe-ingredients ul, .recipe-instructions ol {
  margin: 0;
  padding-left: 1.15rem;
}
.recipe-ingredients li, .recipe-instructions li {
  margin-bottom: 0.4rem;
  font-size: 0.92rem;
}

.recipe-ingredients, .recipe-instructions {
  max-height: 320px;
  overflow-y: auto;
  padding-right: 0.4rem;
}

/* =========================================================
   FOOTER
   ========================================================= */
.site-foot {
  position: relative;
  z-index: 1;
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
  padding: 2.5rem 1.5rem 3.5rem;
}

/* =========================================================
   MOTION PREFERENCES
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cloud { animation: none; }
  .door-leaf { transition: none; }
  .pantry-leaf { transition: none; }
  .pantry-steam { animation: none !important; opacity: 0; }
  button { transition: none; }
  .precip .drop, .precip .flake { animation: none !important; opacity: 0.55; }
  .lightning.flash { animation: none !important; }
}
