/* ==========================================================================
   Santech Innovations — interactive demos
   Styles for the three working demos on the home page. Behaviour is in
   assets/js/demos.js. Uses only the variables in tokens.css.

   1. Shared controls (segmented buttons, selects, checks)
   2. Live demo: schedule app + "behind the scenes" log
   3. Reminder builder + phone
   4. Time-back calculator
   ========================================================================== */

/* 1. Shared controls ------------------------------------------------------ */
.seg {
  display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-pill);
}
.seg button, .seg label span {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px;
  border: 0; border-radius: var(--r-pill); background: transparent;
  font: 600 var(--fs-xs)/1 var(--font-body); color: var(--text-2); cursor: pointer;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.seg button:hover, .seg label:hover span { color: var(--text); }
.seg button[aria-pressed="true"], .seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 1px; }
.seg .icon { width: 16px; height: 16px; }
.seg-lg button, .seg-lg label span { min-height: 42px; padding: 0 16px; font-size: var(--fs-sm); }

.select-wrap select {
  appearance: none; min-height: 44px; padding: 0 40px 0 16px; cursor: pointer;
  font: 600 var(--fs-xs)/1 var(--font-body); color: var(--text);
  background-color: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-pill);
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
}

.check { display: flex; align-items: center; gap: var(--s-3); font-size: var(--fs-sm); color: var(--text); cursor: pointer; }
.check input, .toggle input { width: 20px; height: 20px; accent-color: var(--primary); flex: none; cursor: pointer; }

/* 2. Live demo ------------------------------------------------------------ */
.demo { display: grid; gap: var(--s-4); align-items: start; }
@media (min-width: 1000px) { .demo { grid-template-columns: 1.15fr 0.85fr; gap: var(--s-5); } }

.demo-app {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-2); overflow: hidden; min-height: 520px;
}
.browser-bar {
  display: flex; align-items: center; gap: var(--s-4); padding: 12px var(--s-4);
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.browser-dots { display: flex; gap: 6px; }
.browser-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); }
.browser-url {
  flex: 1; max-width: 320px; padding: 6px 14px; border-radius: var(--r-pill); background: var(--surface);
  font: 500 12px/1.2 var(--font-mono); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.demo-body { padding: var(--s-5) var(--s-4); }
@media (min-width: 620px) { .demo-body { padding: var(--s-6) var(--s-5); } }
.demo-body[hidden] { display: none; }

.demo-filters { display: flex; flex-wrap: wrap; gap: var(--s-3); justify-content: space-between; margin-bottom: var(--s-5); }

.class-list { display: grid; gap: var(--s-3); }
.noscript-note { color: var(--text-3); font-size: var(--fs-sm); }
.class-empty { padding: var(--s-6) var(--s-4); text-align: center; color: var(--text-3); font-size: var(--fs-sm); border: 1px dashed var(--border-strong); border-radius: var(--r-md); }
.class-card {
  display: grid; grid-template-columns: 56px 1fr; gap: var(--s-3) var(--s-4); align-items: center;
  padding: var(--s-4); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  animation: card-in 320ms var(--ease) both;
}
.class-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-1); }
@keyframes card-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.cc-when { text-align: center; line-height: 1.15; padding: var(--s-2) 0; border-radius: var(--r-sm); background: var(--surface-2); }
.cc-day { display: block; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.cc-time { display: block; font: 700 var(--fs-sm)/1.3 var(--font-display); color: var(--text); }
.cc-name { font-weight: 600; color: var(--text); line-height: 1.3; }
.cc-meta { font-size: 13px; color: var(--text-3); }
.cc-cap { display: flex; align-items: center; gap: var(--s-2); margin-top: 6px; }
.cap-bar { flex: 1; max-width: 140px; height: 6px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.cap-bar span { display: block; height: 100%; border-radius: inherit; background: var(--success); transition: width 500ms var(--ease); }
.cap-text { font-size: 12px; font-weight: 600; color: var(--success); white-space: nowrap; }
.class-card.is-low .cap-bar span { background: var(--accent); }
.class-card.is-low .cap-text { color: var(--accent); }
.class-card.is-full .cap-bar span { background: var(--text-3); }
.class-card.is-full .cap-text { color: var(--text-3); }
.cc-action { grid-column: 1 / -1; }
.cc-action .btn { width: 100%; min-height: 42px; }
@media (min-width: 520px) {
  .class-card { grid-template-columns: 64px 1fr auto; }
  .cc-action { grid-column: auto; }
  .cc-action .btn { width: auto; }
}
.cc-booked { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--success); }
.cc-booked .icon { width: 16px; height: 16px; stroke-width: 2.5; }

.back-link {
  display: inline-flex; align-items: center; gap: var(--s-2); padding: var(--s-2) 0; margin-bottom: var(--s-4);
  background: none; border: 0; font: 600 var(--fs-sm)/1 var(--font-body); color: var(--primary); cursor: pointer;
}
.back-link .icon { width: 16px; height: 16px; transform: rotate(180deg); }
.signup-head { margin-bottom: var(--s-5); }
.signup-kicker { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--primary); }
.signup-head h3 { font-size: var(--fs-2xl); margin-top: var(--s-1); }
.signup-head h3:focus { outline: none; }
.signup-meta { margin-top: var(--s-2); font-size: var(--fs-sm); }
.signup-form { display: grid; gap: var(--s-4); max-width: 440px; }
.demo-fine { font-size: 13px; color: var(--text-3); text-align: center; }

.demo-done { display: grid; justify-items: center; text-align: center; gap: var(--s-3); padding-block: var(--s-8); }
.done-icon {
  display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%;
  background: var(--success-soft); color: var(--success); animation: pop 420ms var(--ease) both;
}
.done-icon .icon { width: 30px; height: 30px; stroke-width: 2.5; }
.demo-done h3 { font-size: var(--fs-2xl); }
.demo-done h3:focus { outline: none; }
.demo-done p { max-width: 40ch; }
.demo-done .btn { margin-top: var(--s-3); }
@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 70% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }

/* Behind-the-scenes panel: always dark, like a control room */
.demo-log {
  background: var(--stage-bg); color: var(--stage-text); border: 1px solid var(--stage-border);
  border-radius: var(--r-lg); padding: var(--s-5); min-height: 320px;
  display: flex; flex-direction: column; gap: var(--s-4);
}
@media (min-width: 1000px) { .demo-log { position: sticky; top: calc(var(--header-h) + var(--s-5)); min-height: 520px; } }
.log-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); }
.log-head h3 { color: var(--stage-text); font-size: var(--fs-lg); }
.log-badge {
  font: 500 12px/1 var(--font-mono); padding: 6px 10px; border-radius: var(--r-pill);
  color: var(--stage-text-2); border: 1px solid var(--stage-border);
}
.log-badge.is-running { color: var(--stage-primary); border-color: rgba(142, 174, 255, 0.45); }
.log-badge.is-done { color: var(--stage-success); border-color: rgba(92, 201, 142, 0.45); }
.log-list { display: grid; gap: var(--s-2); }
.log-empty { font-size: var(--fs-sm); color: var(--stage-text-3); padding: var(--s-4); border: 1px dashed var(--stage-border); border-radius: var(--r-md); }
.log-step {
  display: grid; grid-template-columns: 28px 1fr auto; gap: var(--s-3); align-items: start;
  padding: var(--s-3); border-radius: var(--r-md); background: rgba(255, 255, 255, 0.04);
  animation: card-in 360ms var(--ease) both;
}
.log-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: rgba(92, 201, 142, 0.14); color: var(--stage-success); }
.log-icon .icon { width: 15px; height: 15px; stroke-width: 2.25; }
.log-step.is-warn .log-icon { background: rgba(240, 180, 86, 0.14); color: var(--stage-accent); }
.log-step.is-info .log-icon { background: rgba(142, 174, 255, 0.14); color: var(--stage-primary); }
.log-text strong { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--stage-text); line-height: 1.35; }
.log-text small { display: block; font-size: 13px; color: var(--stage-text-3); line-height: 1.4; margin-top: 2px; }
.log-time { font: 500 12px/1.6 var(--font-mono); color: var(--stage-text-3); font-variant-numeric: tabular-nums; }

.email-preview {
  background: var(--stage-text); color: var(--stage-bg); border-radius: var(--r-md); padding: var(--s-4);
  animation: card-in 360ms var(--ease) both;
}
.email-preview[hidden] { display: none; }
.email-top { display: flex; align-items: center; gap: var(--s-2); font-weight: 700; font-size: var(--fs-sm); padding-bottom: var(--s-2); margin-bottom: var(--s-2); border-bottom: 1px solid rgba(11, 14, 20, 0.12); }
.email-top .icon { width: 16px; height: 16px; color: #3A4252; }
.email-preview p { color: #3A4252; font-size: 13px; line-height: 1.55; white-space: pre-line; }
.log-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3); margin-top: auto; }
.demo-log .btn-secondary { color: var(--stage-text); border-color: var(--stage-border-strong); }
.demo-log .btn-secondary:hover { border-color: var(--stage-text); }
.demo-log .btn-text { color: var(--stage-text-2); }
.demo-log .btn-text:hover { color: var(--stage-text); }
.demo-log :focus-visible { outline-color: var(--stage-primary); }

/* 3. Reminder builder ----------------------------------------------------- */
.rem-grid { display: grid; gap: var(--s-7); align-items: center; }
@media (min-width: 1000px) { .rem-grid { grid-template-columns: 1.1fr 0.9fr; gap: var(--s-9); } }
.rem-copy h2 { margin-top: var(--s-2); }
.rem-controls { display: grid; gap: var(--s-5); margin-top: var(--s-6); }
.rem-controls fieldset { border: 0; padding: 0; min-width: 0; }
.rem-controls legend { font-size: var(--fs-sm); font-weight: 600; color: var(--text); margin-bottom: var(--s-2); }
.rem-controls .seg { background: var(--surface); }
.rem-controls .seg input:checked + span { background: var(--primary); color: var(--on-primary); box-shadow: none; }
.toggles { display: flex; flex-wrap: wrap; gap: var(--s-3) var(--s-5); }
.toggle { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); font-weight: 500; color: var(--text); cursor: pointer; }

.phone-wrap { display: grid; place-items: center; }
.phone {
  position: relative; width: 300px; max-width: 100%; aspect-ratio: 300 / 560;
  background: var(--stage-bg); border-radius: 44px; padding: 14px;
  box-shadow: 0 0 0 2px #2A303B, 0 40px 80px -24px rgba(11, 14, 20, 0.45);
}
.phone-notch { position: absolute; top: 22px; left: 50%; width: 92px; height: 24px; margin-left: -46px; border-radius: var(--r-pill); background: #000; z-index: 1; }
.phone-screen {
  height: 100%; border-radius: 32px; background: #F2F3F6; padding: 64px var(--s-4) var(--s-4);
  display: flex; flex-direction: column; gap: var(--s-2); overflow: hidden;
}
.phone-meta { text-align: center; font-size: 12px; font-weight: 600; color: #5E6573; }
.bubble {
  align-self: flex-start; max-width: 88%; padding: var(--s-3) var(--s-4);
  background: #FFFFFF; border-radius: 20px 20px 20px 6px; box-shadow: 0 1px 2px rgba(11, 14, 20, 0.08);
  transition: border-radius var(--dur) var(--ease);
}
.bubble p { color: #15171B; font-size: 14px; line-height: 1.45; white-space: pre-line; }
.bubble.is-email { align-self: stretch; max-width: none; border-radius: 14px; }
.bubble-subject { font-weight: 700; padding-bottom: var(--s-2); margin-bottom: var(--s-2); border-bottom: 1px solid #E4E6EB; }
.bubble.is-updated { animation: nudge 360ms var(--ease); }
@keyframes nudge { 0% { transform: scale(0.97); } 60% { transform: scale(1.015); } 100% { transform: scale(1); } }
.phone-sent { font-size: 12px; color: #5E6573; padding-left: var(--s-2); }

/* 4. Time-back calculator ------------------------------------------------- */
.calc { display: grid; gap: var(--s-4); }
@media (min-width: 1000px) { .calc { grid-template-columns: 1.2fr 0.8fr; gap: var(--s-5); align-items: stretch; } }
.calc-inputs {
  display: grid; gap: var(--s-6); padding: var(--s-6) var(--s-5);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
}
@media (min-width: 620px) { .calc-inputs { padding: var(--s-7) var(--s-6); } }
.range-top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-4); margin-bottom: var(--s-3); }
.range-top label { font-weight: 600; color: var(--text); font-size: var(--fs-sm); }
.range-top output { font: 700 var(--fs-xl)/1 var(--font-display); color: var(--primary); font-variant-numeric: tabular-nums; min-width: 3ch; text-align: right; }
.range-hint { margin-top: var(--s-2); font-size: 13px; color: var(--text-3); }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; cursor: pointer;
  --fill: 50%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: var(--r-pill);
  background: linear-gradient(to right, var(--primary) var(--fill), var(--surface-2) var(--fill));
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: var(--r-pill); background: var(--surface-2); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: var(--r-pill); background: var(--primary); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--primary); box-shadow: var(--shadow-1);
}
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--primary); box-shadow: var(--shadow-1);
}
input[type="range"]:focus-visible { outline: 3px solid var(--primary); outline-offset: 4px; }

.calc-result {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; flex-direction: column; gap: var(--s-3); justify-content: center;
  padding: var(--s-7) var(--s-5); border-radius: var(--r-lg);
  background: var(--stage-bg); color: var(--stage-text);
}
.calc-result::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: radial-gradient(70% 60% at 100% 0%, rgba(91, 132, 255, 0.3), transparent 70%);
}
@media (min-width: 620px) { .calc-result { padding: var(--s-7) var(--s-6); } }
.calc-label { font-size: var(--fs-sm); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--stage-text-2); }
.calc-big { display: flex; align-items: baseline; gap: var(--s-2); font: 800 clamp(4rem, 3rem + 5vw, 6rem)/1 var(--font-display); letter-spacing: -0.04em; color: var(--stage-text); font-variant-numeric: tabular-nums; }
.calc-unit { font-size: var(--fs-xl); font-weight: 600; letter-spacing: 0; color: var(--stage-text-2); }
.calc-year { color: var(--stage-text-2); font-size: var(--fs-base); }
.calc-year strong { color: var(--stage-accent); font-weight: 700; }
.calc-formula { font: 500 12px/1.5 var(--font-mono); color: var(--stage-text-3); }
.calc-result .btn { margin-top: var(--s-4); }
.calc-result :focus-visible { outline-color: var(--stage-primary); }

@media (prefers-reduced-motion: reduce) {
  .class-card, .log-step, .email-preview, .done-icon, .bubble.is-updated { animation: none !important; }
}
