/* ============================================
   ไทยช่วยไทย พลัส 60/40 Calculator
   Theme: Brand sky-blue × navy × lime-green
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@300;400;500;600;700;800;900&family=IBM+Plex+Sans+Thai:wght@300;400;500;600;700&display=swap');

/* ── Tokens ────────────────────────────────── */
:root {
  /* Brand palette from web-app-share.jpeg */
  --sky:         #71C9F0;   /* background sky */
  --sky-light:   #B8E8FA;
  --sky-dark:    #3FA8DC;
  --navy:        #1B3F8B;   /* logo navy */
  --navy-dark:   #122B64;
  --navy-mid:    #2A52A8;
  --lime:        #6DC52A;   /* "พลัส" / "60/40" green */
  --lime-dark:   #4E9A18;
  --lime-light:  #D4F5A8;
  --red:         #E8192C;   /* Thai flag red */
  --red-light:   #FFE5E8;

  /* Neutrals */
  --white:       #FFFFFF;
  --off-white:   #F6FBFF;
  --gray-50:     #F4F8FC;
  --gray-100:    #E8F0F8;
  --gray-200:    #D0DFF0;
  --gray-400:    #8BA4C8;
  --gray-600:    #4A6080;
  --gray-900:    #0F1E35;

  /* Semantic */
  --bg:          var(--sky-light);
  --surface:     var(--white);
  --text:        var(--gray-900);
  --text-muted:  var(--gray-600);
  --border:      var(--gray-100);

  /* Radius */
  --r-sm:  8px;
  --r-md:  14px;
  --r-lg:  20px;
  --r-xl:  28px;
  --r-2xl: 36px;

  /* Shadow */
  --shadow-card: 0 2px 24px rgba(27,63,139,0.10), 0 1px 4px rgba(27,63,139,0.06);
  --shadow-btn:  0 4px 16px rgba(27,63,139,0.30);
  --shadow-inset: inset 0 1px 3px rgba(27,63,139,0.08);

  font-family: 'IBM Plex Sans Thai', 'Noto Sans Thai', sans-serif;
}

/* ── Reset ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-main);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font-family: inherit; cursor: pointer; border: none; }
input  { font-family: inherit; }

/* ── Page ──────────────────────────────────── */
.page-bg {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 140% 60% at 50% -10%, #C8EEFB 0%, transparent 70%),
    linear-gradient(175deg, #A8DEFA 0%, #71C9F0 35%, #4AAEE0 65%, #2F93CC 100%);
  padding-bottom: 48px;
}

/* Decorative orbs */
.page-bg::before, .page-bg::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}
.page-bg::before {
  width: 420px; height: 420px;
  top: -120px; right: -100px;
  background: radial-gradient(circle, rgba(255,255,255,0.18) 0%, transparent 70%);
}
.page-bg::after {
  width: 300px; height: 300px;
  bottom: 60px; left: -80px;
  background: radial-gradient(circle, rgba(109,197,42,0.12) 0%, transparent 70%);
}

.container {
  max-width: 460px;
  margin: 0 auto;
  padding: 0 16px;
  position: relative;
  z-index: 1;
}

/* ── Header ────────────────────────────────── */
.header {
  /* no top padding – image bleeds from very top */
  padding: 0 0 16px;
  text-align: center;
  /* break out of container padding */
  margin-left: -16px;
  margin-right: -16px;
}

.header-logo-img {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
  /* fade bottom edge into the sky-blue page background */
  -webkit-mask-image: linear-gradient(
    to bottom,
    black 0%,
    black 60%,
    transparent 100%
  );
  mask-image: linear-gradient(
    to bottom,
    black 0%,
    black 60%,
    transparent 100%
  );
}

.header-subtitle {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--navy-dark);
  background: rgba(255,255,255,0.70);
  backdrop-filter: blur(6px);
  border-radius: 100px;
  padding: 4px 14px;
  margin-top: -8px;   /* overlap slightly onto faded image */
  position: relative;
  z-index: 2;
  letter-spacing: 0.3px;
}

/* ── Info Pills ────────────────────────────── */
.info-pills {
  display: flex;
  gap: 8px;
  margin: 0 16px 18px;  /* restore side spacing after header bleed */
  flex-wrap: wrap;
}

.pill {
  display: flex;
  align-items: center;
  gap: 6px;
  /* Navy-tinted background – white text reads clearly */
  background: rgba(27,63,139,0.65);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 100px;
  padding: 7px 12px;
  flex: 1;
  min-width: 0;
}

.pill-icon { font-size: 0.9rem; flex-shrink: 0; }
.pill-text {
  font-size: 0.72rem;
  color: var(--white);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.pill-text small {
  display: block;
  font-weight: 400;
  color: rgba(255,255,255,0.72);
  font-size: 0.68rem;
}

/* ── Card ──────────────────────────────────── */
.calc-card {
  background: var(--white);
  border-radius: var(--r-xl);
  padding: 28px 22px 22px;
  box-shadow: var(--shadow-card);
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}

/* Top colour stripe */
.calc-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--red) 0%, var(--navy) 50%, var(--lime) 100%);
}

.calc-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 20px;
  letter-spacing: -0.2px;
}

/* ── Inputs ────────────────────────────────── */
.input-group { margin-bottom: 18px; }

.input-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 7px;
}
.label-icon { font-size: 0.95rem; }

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-field {
  width: 100%;
  padding: 13px 44px 13px 15px;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text);
  background: var(--gray-50);
  border: 1.5px solid var(--gray-100);
  border-radius: var(--r-md);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
  -moz-appearance: textfield;
}
.input-field::-webkit-outer-spin-button,
.input-field::-webkit-inner-spin-button { -webkit-appearance: none; }

.input-field::placeholder { color: var(--gray-400); font-weight: 400; }

.input-field:focus {
  border-color: var(--navy-mid);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(27,63,139,0.10);
}
.input-field.error {
  border-color: var(--red);
  background: var(--red-light);
  box-shadow: 0 0 0 3px rgba(232,25,44,0.10);
}

.input-unit {
  position: absolute;
  right: 14px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-400);
  pointer-events: none;
}

.input-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 5px;
  line-height: 1.4;
}
.input-error {
  font-size: 0.78rem;
  color: var(--red);
  margin-top: 4px;
  min-height: 18px;
  font-weight: 500;
}

/* ── Calculate Button ──────────────────────── */
.calc-btn {
  width: 100%;
  padding: 15px 24px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--white);
  background: linear-gradient(135deg, var(--navy-mid) 0%, var(--navy) 100%);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.18s, box-shadow 0.18s;
  box-shadow: var(--shadow-btn);
  position: relative;
  overflow: hidden;
  margin-bottom: 22px;
}
.calc-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.12) 0%, transparent 60%);
}
.calc-btn:hover  { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(27,63,139,0.38); }
.calc-btn:active { transform: translateY(0); }
.btn-icon { font-size: 1.1rem; position: relative; z-index: 1; }
.calc-btn span:last-child { position: relative; z-index: 1; }

/* ── Results ───────────────────────────────── */
.results-section { display: none; }
.results-section.visible { display: block; animation: fadeUp 0.35s ease both; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}

/* Max-daily box */
.result-main {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 60%, #3563C4 100%);
  border-radius: var(--r-lg);
  padding: 20px 18px 16px;
  margin-bottom: 10px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.result-main::before {
  content: '';
  position: absolute;
  top: -40px; right: -30px;
  width: 180px; height: 180px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
}
.result-main-label {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.85);
  font-weight: 600;
  margin-bottom: 6px;
  position: relative;
  z-index: 1;
}
.result-main-amount {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  position: relative;
  z-index: 1;
}
#result-max-daily-value {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--lime);
  line-height: 1;
  letter-spacing: -1px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.20);
}
.result-unit {
  font-size: 1.1rem;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
}
.result-main-note {
  font-size: 0.76rem;
  color: rgba(255,255,255,0.72);
  margin-top: 7px;
  position: relative;
  z-index: 1;
  background: rgba(0,0,0,0.12);
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
}
.result-main-amount.updated { animation: pulse 0.45s ease; }

/* Muted split row */
.result-split-muted {
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--r-md);
  padding: 10px 14px;
  margin-bottom: 12px;
}
.split-muted-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}
.split-muted-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.split-muted-item {
  font-size: 0.88rem;
  color: var(--gray-600);
  font-weight: 500;
}
.split-muted-item strong {
  font-weight: 800;
  font-size: 0.95rem;
}
.split-muted-item.you strong { color: var(--navy); }
.split-muted-item.gov strong { color: var(--lime-dark); }
.split-muted-sep { color: var(--gray-400); font-size: 0.85rem; font-weight: 600; }

/* Actual payment box */
.result-actual {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 55%, #3563C4 100%);
  border-radius: var(--r-lg);
  padding: 18px 16px 14px;
  margin-bottom: 10px;
  position: relative;
  overflow: hidden;
}
.result-actual::before {
  content: '';
  position: absolute;
  top: -30px; right: -20px;
  width: 140px; height: 140px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
  pointer-events: none;
}
.result-actual-label {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.82);
  font-weight: 600;
  text-align: center;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
  background: rgba(0,0,0,0.15);
  display: inline-block;
  width: 100%;
  padding: 4px 10px;
  border-radius: 100px;
}
.result-actual-cards {
  display: flex;
  position: relative;
  z-index: 1;
  gap: 10px;
}
.actual-card {
  flex: 1;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.20);
  border-radius: var(--r-md);
  padding: 16px 10px 12px;
  text-align: center;
}
.actual-icon { font-size: 1.3rem; margin-bottom: 5px; }
.actual-card-label {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.80);
  margin-bottom: 6px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.actual-amount {
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 3px;
  letter-spacing: -0.5px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.20);
}
.actual-card.you .actual-amount { color: #FFD93D; }
.actual-card.gov .actual-amount { color: #7EE83A; }
.actual-unit { font-size: 0.75rem; color: rgba(255,255,255,0.65); font-weight: 500; }

/* hide old divider – cards use gap instead */
.actual-divider { display: none; }
.actual-plus    { display: none; }

.result-actual-savings {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.65);
  text-align: center;
  margin-top: 12px;
  position: relative;
  z-index: 1;
  font-weight: 500;
}
.result-actual-savings.has-savings {
  color: #7EE83A;
  font-weight: 700;
  font-size: 0.86rem;
}

/* Remaining */
.result-remaining {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #EBF5FF;
  border: 1.5px solid #C3DFFE;
  border-radius: var(--r-md);
  padding: 11px 15px;
  margin-bottom: 10px;
}
.remaining-label  { font-size: 0.8rem; color: var(--navy); font-weight: 500; }
.remaining-amount { font-size: 0.95rem; font-weight: 700; color: var(--navy-dark); }

/* Warning */
.result-warning {
  background: #FFFBEB;
  border: 1.5px solid #FDE68A;
  border-radius: var(--r-md);
  padding: 11px 14px;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-bottom: 10px;
  font-size: 0.8rem;
  color: #78350F;
  font-weight: 500;
  line-height: 1.5;
}
.warning-icon { flex-shrink: 0; font-size: 1rem; margin-top: 1px; }

/* Reset button */
.reset-btn {
  width: 100%;
  padding: 11px 20px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: all 0.18s;
  margin-top: 4px;
}
.reset-btn:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
  color: var(--text);
}

/* ── How-it-works card ─────────────────────── */
.how-card {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.55);
  border-radius: var(--r-xl);
  padding: 22px 20px;
  margin-bottom: 14px;
  box-shadow: 0 2px 16px rgba(27,63,139,0.07);
}

.how-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.how-title::before { content: '📖'; font-size: 0.95rem; }

.how-steps { display: flex; flex-direction: column; gap: 9px; margin-bottom: 14px; }
.how-step  { display: flex; align-items: flex-start; gap: 10px; }

.step-num {
  min-width: 24px;
  height: 24px;
  background: var(--navy);
  color: var(--white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}

.step-text {
  font-size: 0.84rem;
  color: var(--gray-600);
  padding-top: 3px;
  line-height: 1.5;
}
.step-text strong { color: var(--navy); }

.example-box {
  background: linear-gradient(135deg, #EBF5FF 0%, #F0FAE8 100%);
  border-radius: var(--r-md);
  padding: 13px 15px;
  border: 1px solid var(--gray-200);
}
.example-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 7px;
}
.example-content {
  font-size: 0.82rem;
  color: var(--gray-600);
  line-height: 1.9;
}
.gov-color  { color: var(--lime-dark) !important; }
.you-color  { color: var(--navy)      !important; }

/* ── Footer ────────────────────────────────── */
.footer {
  margin-top: 4px;
  padding: 0 0 24px;
}

.footer-inner {
  background: rgba(27,63,139,0.55);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: var(--r-xl);
  padding: 20px 22px;
  text-align: center;
}

.footer-logo {
  font-size: 1rem;
  font-weight: 800;
  color: var(--white);
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}
.footer-logo span { color: var(--lime); }

.footer-period {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.65);
  font-weight: 500;
  margin-bottom: 14px;
}

.footer-divider {
  height: 1px;
  background: rgba(255,255,255,0.12);
  margin: 14px 0;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.footer-link {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.70);
  text-decoration: none;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 100px;
  padding: 5px 12px;
  font-weight: 500;
  transition: background 0.18s, color 0.18s;
}
.footer-link:hover {
  background: rgba(255,255,255,0.20);
  color: var(--white);
}

.footer-credit {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.40);
}
.footer-credit a {
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.18s;
}
.footer-credit a:hover { color: var(--white); }

/* ── Responsive ────────────────────────────── */
@media (max-width: 360px) {
  #result-max-daily-value { font-size: 2rem; }
  .actual-amount { font-size: 1.5rem; }
  .calc-card { padding: 22px 16px 18px; }
}

/* ── Shake animation ───────────────────────── */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-5px); }
  40%      { transform: translateX(5px); }
  60%      { transform: translateX(-3px); }
  80%      { transform: translateX(3px); }
}
.input-field.shake { animation: shake 0.38s ease; }
