/* -----------------------------------------------------------
   GLOBAL THEME
----------------------------------------------------------- */
:root {
  --bg: #f5f6f7;
  --card: #ffffff;
  --text: #1a1a1c;
  --muted: #6e6e73;
  --border: rgba(0,0,0,0.08);
  --accent: #0a84ff;
  --radius: 20px;
  --shadow: 0 8px 22px rgba(0,0,0,0.08);

  --desktop-width: 900px;
  --sidebar-width: 300px;
  --block-gap: 32px;
  
}

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

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  line-height: 1.55;
}

/* Prevent mobile Safari zoom on inputs */
input, select, textarea, button {
  font-size: 16px;
}

/* -----------------------------------------------------------
   PAGE WRAPPERS
----------------------------------------------------------- */
.page {
  width: 100%;
  display: flex;
  justify-content: center;
}

.page-inner {
  width: 100%;
  max-width: var(--desktop-width);
  padding: 24px 16px;
  margin: 0 auto;
}

/* -----------------------------------------------------------
   TYPOGRAPHY
----------------------------------------------------------- */
h1, h2, h3 {
  margin: 0 0 12px 0;
  font-weight: 600;
}

h1 {
  font-size: 32px;
  margin-top: 12px;
}

p {
  margin: 8px 0 16px 0;
  color: var(--muted);
}

/* -----------------------------------------------------------
   GRID LAYOUT (DESKTOP)
----------------------------------------------------------- */
.layout-grid {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-width);
  gap: 32px;
  margin-top: 24px;
}

.content-column {
  width: 100%;
}

.sidebar-column {
  width: 100%;
}

.sidebar-stack {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* -----------------------------------------------------------
   CARD ELEMENTS
----------------------------------------------------------- */
.card,
.sidebar-card,
.support-box,
.ad-container,
.top-support-box,
.result {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 28px;
  width: 100%;
}

.card,
.result,
.support-box,
.ad-container {
  margin-bottom: var(--block-gap);
}

/* -----------------------------------------------------------
   ARTICLE CONTENT
----------------------------------------------------------- */
.article-ads {
  background: var(--card);
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

/* Ensure article images are clean and contained */
.content-column img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  margin: 16px 0;
}

/* -----------------------------------------------------------
   CALCULATOR FORM
----------------------------------------------------------- */
form {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px 20px;
  margin-top: 12px;
}

label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  color: var(--muted);
}

input {
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fafafa;
  transition: border 0.2s ease, background 0.2s ease;
}

input:focus {
  background: #ffffff;
  border-color: var(--accent);
  outline: none;
}

.button-row {
  grid-column: span 3;
  display: flex;
  justify-content: center;
}

/* CALCULATE BUTTON */
button.calculate {
  padding: 14px 28px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s ease;
}

button.calculate:hover {
  background: #0062d6;
}

/* -----------------------------------------------------------
   TEMPERATURE UNIT TOGGLE
----------------------------------------------------------- */
.unit-toggle {
  display: inline-flex;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
}

.unit-toggle button {
  padding: 8px 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
}

.unit-toggle button.active {
  background: var(--accent);
  color: #ffffff;
}

/* -----------------------------------------
   SIMPLE / ADVANCED MODE TOGGLE FIXED
------------------------------------------ */
.mode-toggle {
  display: inline-flex;
  gap: 10px;
}

.mode-toggle button {
  background: #ffffff;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 8px 18px;
  border-radius: 12px;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-toggle button.active-mode {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(10,132,255,0.25);
}
 
/* -----------------------------------------------------------
   RESULTS BOX
----------------------------------------------------------- */

.result-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.result-section:last-child {
  border-bottom: none;
}

.result strong {
  font-size: 18px;
  font-weight: 600;
}

.result-value {
  margin: 4px 0 12px 0;
  color: var(--text);
}


/* -----------------------------------------------------------
   STATUS BADGES
----------------------------------------------------------- */
.status-badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
}

.badge-cool { background: #e0f2fe; color: #0369a1; }
.badge-warm { background: #fef3c7; color: #92400e; }
.badge-balanced { background: #dcfce7; color: #166534; }

/* -----------------------------------------------------------
   MOBILE (UNDER 899PX)
----------------------------------------------------------- */
@media (max-width: 899px) {
  .layout-grid {
    grid-template-columns: 1fr;
  }
  .sidebar-column {
    order: 3;
  }
}

/* -----------------------------------------------------------
   MOBILE FULL BLEED (UNDER 599PX)
----------------------------------------------------------- */
@media (max-width: 599px) {

  /* MOBILE INPUT PATCH */
  input {
    padding: 8px 10px;
    font-size: 14px;
    border-radius: 10px;
  }

  label {
    font-size: 12px;
    margin-bottom: 2px;
  }

  form {
    gap: 10px 12px;
  }

  .mode-toggle,
  .unit-toggle {
    transform: scale(0.9);
    transform-origin: left center;
    margin-bottom: 8px;
  }

  #calculator.card {
    padding: 18px;
    border-radius: 12px;
  }

  .page-inner {
    padding: 16px 10px;
  }

  .card,
  .sidebar-card,
  .result,
  .support-box,
  .top-support-box,
  .ad-container,
  #calculator {
    padding: 20px;
    border-radius: 0;
    width: 100%;
    margin-bottom: var(--block-gap);
  }

  form {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }

  form label input {
    width: 100%;
    max-width: 100%;
  }

  input {
    padding: 10px 10px;
  }

  label {
    max-width: 100%;
  }

  .button-row {
    grid-column: span 2;
  }

  h1 {
    font-size: 26px;
  }

  /* FINAL HARD‑FIX FOR MOBILE WIDTH UNIFICATION */
  .card,
  #calculator,
  .result,
  .support-box,
  .ad-container,
  .sidebar-card {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    border-radius: 14px !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  /* Prevent overflow caused by grid items */
  form label,
  form input {
    max-width: 100% !important;
  }

  /* Fix for side spacing inconsistencies */
  .page-inner,
  .content-column,
  .sidebar-column {
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
  }

  /* FIX: Ensure multi-line labels like Room Temp and Start Time never overflow */
  form label.span-2 {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    white-space: normal !important;
  }

  form label.span-2 input {
    width: 100% !important;
    max-width: 100% !important;
  }
}


/* -----------------------------------------------------------
   COLLAPSE EMPTY AD SLOTS
----------------------------------------------------------- */

/* Hide empty Google ad containers */
.adsbygoogle:empty {
  display: none !important;
}

/* Hide sidebar cards that only contain empty ads */
.sidebar-card:has(.adsbygoogle:empty) {
  display: none;
}

/* -----------------------------------------------------------
   Center Coffee button
----------------------------------------------------------- */

/* Centre Buy Me a Coffee button */
.support-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}


/* -----------------------------------------------------------
   FINAL FIX: CENTER COFFEE BUTTON + CARD SPACING
----------------------------------------------------------- */

.support-box a {
  display: flex;
  justify-content: center;
}

/* Starter calculator label fix only */
#calculator label {
  white-space: nowrap;
}

#calculator label input {
  white-space: normal;
}

.card {
  position: relative;
}

.card-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.unit-toggle {
  display: inline-flex;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.unit-toggle button {
  padding: 6px 12px;
  font-size: 13px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
}

.unit-toggle button.active {
  background: var(--accent);
  color: #ffffff;
}

.key-question {
  max-width: 760px;
  margin: 12px 0 20px;
  padding-left: 12px;
  border-left: 3px solid var(--accent);
  color: var(--text);
}

.key-question-box {
  margin: 12px 0 20px;
  padding: 12px 16px;
  border-left: 3px solid var(--accent);
  background: #f8f9fb;
  border-radius: 12px;
}

/* -----------------------------------------------------------
   RESULT COLLAPSE OVERRIDE
----------------------------------------------------------- */

.result {
  overflow: hidden;
  transition: max-height 0.35s ease, opacity 0.25s ease;
  max-height: 2000px;
  opacity: 1;
}

.result.collapsed {
  max-height: 0;
  opacity: 0;
  padding: 0;
  margin: 0;
  border: 0;
  box-shadow: none;
}

  
  /* Calculator embed card fix */
.card.apple-upgraded {
  padding: 0;
  background: #ffffff;
}

/* Ensure iframe fills its container cleanly */
.card.apple-upgraded iframe {
  display: block;
}

.calculator-shell {
  padding: 28px;
  background: var(--card);
}

.calculator-title {
  margin-bottom: 12px;
}

#calculator {
  scroll-margin-top: 120px;
}

.calculator-shell > .result {
  margin-top: 32px;
}


/* -----------------------------------------------------------
   SHARE RESULTS BUTTON
----------------------------------------------------------- */

.share-results-btn {
  appearance: none;
  -webkit-appearance: none;
  margin-top: 20px;
  padding: 12px 22px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(10,132,255,0.25);
}

.share-results-btn:hover {
  background: #0062d6;
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(10,132,255,0.35);
}

.share-results-btn:active {
  transform: translateY(0);
  box-shadow: 0 4px 14px rgba(10,132,255,0.25);
}

.share-results-btn:focus {
  outline: none;
  box-shadow:
    0 0 0 2px rgba(10,132,255,0.35),
    0 6px 18px rgba(10,132,255,0.25);
}