/* =========================================================
   Temia website updates
   Load AFTER css/styles.css. Uses only the existing design tokens
   (--navy, --amber, --btn, --line, --r, --r-sm, --navy-wash ...).
   Every selector below is new or scoped to .topbar / .demo / .promo,
   so no existing section is restyled.

   1. Header: single access button + brand/nav divider
   2. Free offer band
   3. Footer links
   4. Book a demo page
   5. Form fields
   6. Country code selector
   7. Success state
   ========================================================= */

/* Country flags as a font, so flags also render on Windows (which has no flag emoji).
   Twemoji Country Flags, CC-BY 4.0 graphics, from the country-flag-emoji-polyfill package (MIT). */
@font-face {
  font-family: "Twemoji Country Flags";
  font-display: swap;
  unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E0063, U+E0065, U+E0067, U+E006C, U+E006E, U+E0073-E0074, U+E0077, U+E007F;
  src: url("../fonts/TwemojiCountryFlags.woff2") format("woff2");
}

/* The page toggles views and states with the `hidden` attribute. */
#siteView[hidden], .demo-view[hidden], .demo-view [hidden] { display: none !important; }

/* ---------- 1. Header ---------- */
.topbar .btn-access:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.topbar .nav { align-items: center; margin-left: clamp(2px, 1vw, 18px); }
.topbar .nav::before { content: ""; flex: none; width: 1px; height: 24px; background: var(--sh20); margin-right: clamp(6px, 1.2vw, 22px); }

/* ---------- 2. Free offer band ---------- */
.section.promo { padding-top: 0; }
.promo-card {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: clamp(24px, 4vw, 64px);
  padding: clamp(28px, 4.4vw, 56px);
  border-radius: var(--r); border-top: 3px solid var(--amber);
  background: var(--navy-wash); color: var(--white);
}
.promo-copy { display: grid; gap: 18px; justify-items: start; min-width: 0; }
.promo-card .h2 { color: var(--white); text-wrap: balance; }
.promo-card .lead { color: var(--on-navy); max-width: 52ch; }
.promo-ctas { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.promo-ctas .btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.promo-price {
  display: grid; justify-items: center; gap: 6px; text-align: center;
  padding: clamp(20px, 2.6vw, 32px) clamp(24px, 3.4vw, 48px);
  border-radius: var(--r); border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.06);
}
.promo-zero { font-size: clamp(64px, 8vw, 112px); font-weight: 600; line-height: 1; letter-spacing: -0.03em; color: var(--amber); font-variant-numeric: tabular-nums; }
.promo-zero-cap { font-size: 12.5px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--on-navy); }
:lang(ja) .promo-zero-cap { letter-spacing: .02em; }

@media (max-width: 860px) {
  .promo-card { grid-template-columns: minmax(0, 1fr); }
  .promo-price { order: -1; justify-self: start; grid-auto-flow: column; align-items: center; gap: 16px; padding: 14px 20px; }
  .promo-zero { font-size: 48px; }
}
@media (max-width: 720px) {
  .promo-ctas { width: 100%; }
  .promo-ctas .btn { flex: 1 1 auto; }
}

/* ---------- 3. Footer links ---------- */
.foot-links { display: flex; flex-wrap: wrap; gap: 6px 22px; }
.foot-link { border: 0; background: none; padding: 0; font: inherit; font-size: 12.5px; color: var(--on-navy); text-decoration: none; cursor: pointer; transition: color .2s; }
.foot-link:hover { color: var(--white); text-decoration: underline; text-underline-offset: 3px; }
.foot-link:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }

/* ---------- 4. Book a demo page ---------- */
.demo {
  min-height: 100vh; display: flex; flex-direction: column; justify-content: space-between; gap: clamp(40px, 5vw, 64px);
  padding-top: calc(64px + clamp(40px, 5vw, 72px)); padding-bottom: 28px;
  color: var(--white); background: var(--navy-wash);
}
.demo-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: clamp(32px, 5vw, 80px); align-items: start; }
.demo-copy { display: grid; gap: 20px; justify-items: start; align-content: start; min-width: 0; }
.demo-back { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13.5px; color: var(--on-navy); text-decoration: none; }
.demo-back .ico { width: 16px; height: 16px; transform: rotate(180deg); }
.demo-back:hover { color: var(--white); }
.demo-back:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }
.demo-title { text-wrap: balance; outline: none; }
.demo .demo-ticks { margin-top: 8px; }
.demo .demo-ticks li { color: var(--on-navy); }
.demo .demo-ticks li::before { filter: brightness(0) invert(1); opacity: .9; }
.demo-card { min-width: 0; padding: clamp(22px, 3vw, 36px); border-radius: var(--r); background: var(--white); color: var(--ink); box-shadow: var(--shadow-frame); }
.demo-foot { margin-top: 0; }

@media (max-width: 960px) {
  .demo-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- 5. Form fields ---------- */
.demo-form { display: grid; gap: 18px; }
.demo-form-head { display: grid; gap: 4px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.demo-form-head h2, .demo-done h2 { color: var(--navy); }
.demo-form-head p { font-size: 13px; color: var(--ink-3); }

.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 16px; }
.field label { font-size: 13.5px; font-weight: 500; color: var(--ink-2); }
.field .opt { margin-left: 4px; font-size: 12px; font-weight: 400; color: var(--sh60); }

.field input[type="text"], .field input[type="email"], .field input[type="tel"], .field select, .field textarea {
  width: 100%; min-width: 0; height: 46px; padding: 0 12px;
  font: inherit; font-size: 15px; color: var(--ink);
  background-color: var(--white); border: 1px solid var(--sh20); border-radius: var(--r-sm);
  transition: border-color .2s, box-shadow .2s;
}
.field textarea { height: auto; min-height: 104px; padding: 10px 12px; line-height: 1.55; resize: vertical; }
.field select {
  appearance: none; -webkit-appearance: none; padding-right: 38px; text-overflow: ellipsis; cursor: pointer;
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233D598C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
.field select.is-empty { color: var(--sh60); }
.field select option { color: var(--ink); }
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--s60); }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--p20); }
.field [aria-invalid="true"] { border-color: var(--red); }
.field [aria-invalid="true"]:focus-visible { box-shadow: 0 0 0 3px var(--red-10); }
.field-hint { font-size: 12.5px; color: var(--sh60); line-height: 1.45; }
.field-err { font-size: 12.5px; color: var(--red); line-height: 1.4; }
.form-err { padding: 10px 12px; border-radius: var(--r-sm); background: var(--red-10); font-size: 13.5px; color: var(--red); line-height: 1.5; }

.demo-submit { width: 100%; margin-top: 4px; }
.demo-submit[disabled] { opacity: .65; cursor: progress; }
.demo-submit:focus-visible, .demo-done .btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

@media (max-width: 560px) {
  .field-row { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- 6. Country code selector ---------- */
.phone { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); }
.cc { position: static; }
.cc-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 46px; padding: 0 8px 0 12px;
  font: inherit; font-size: 15px; color: var(--ink); white-space: nowrap;
  background: var(--s5); border: 1px solid var(--sh20); border-right: 0; border-radius: var(--r-sm) 0 0 var(--r-sm);
  cursor: pointer; transition: background-color .2s, border-color .2s, box-shadow .2s;
}
.cc-btn:hover { background: var(--s10); }
.cc-btn:focus-visible, .cc-btn[aria-expanded="true"] { outline: none; position: relative; z-index: 1; border-color: var(--blue); box-shadow: 0 0 0 3px var(--p20); }
.cc-btn .ico { width: 14px; height: 14px; color: var(--s80); transition: transform .2s; }
.cc-btn[aria-expanded="true"] .ico { transform: rotate(180deg); }
.cc-flag { font-family: "Twemoji Country Flags", "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; font-size: 18px; line-height: 1; }
.cc-dial { font-variant-numeric: tabular-nums; }
.phone > input[type="tel"] { border-radius: 0 var(--r-sm) var(--r-sm) 0; }

.cc-pop {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; width: min(340px, 100%); min-width: min(280px, calc(100vw - 64px));
  display: grid; gap: 8px; padding: 8px;
  background: var(--white); border: 1px solid var(--sh20); border-radius: var(--r); box-shadow: var(--shadow-soft);
}
.field .cc-search { height: 38px; font-size: 14px; }
.cc-list { list-style: none; margin: 0; padding: 0; max-height: 232px; overflow-y: auto; overscroll-behavior: contain; }
.cc-opt { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r-sm); font-size: 14px; color: var(--ink); cursor: pointer; }
.cc-opt .cc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-opt .cc-code { color: var(--sh60); font-variant-numeric: tabular-nums; }
.cc-opt.is-active { background: var(--p10); }
.cc-opt[aria-selected="true"] { font-weight: 500; color: var(--navy); }
.cc-opt[aria-selected="true"] .cc-code { color: var(--navy); }
.cc-empty { padding: 10px; font-size: 13.5px; color: var(--sh60); }

/* ---------- 7. Success state ---------- */
.demo-done { display: grid; gap: 14px; justify-items: start; padding-block: clamp(12px, 3vw, 40px); outline: none; }
.demo-done-ico { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--green-10); color: var(--green); }
.demo-done-ico .ico { width: 26px; height: 26px; stroke-width: 2.2; }
.demo-done p { max-width: 44ch; font-size: 15.5px; line-height: 1.65; color: var(--ink-3); }
.demo-done .btn { margin-top: 10px; }

@media (prefers-reduced-motion: reduce) {
  .cc-btn .ico, .field input, .field select, .field textarea { transition: none; }
}
@media print {
  .demo-view, .topbar .nav::before { display: none !important; }
}

/* ---------- 8. Contact Us page (contact.html) ----------
   Reuses the Book a Demo layout (.demo, .demo-card, .field, .cc …); only the parts below are new. */
.contact-page { background: var(--navy); }
.contact-view [hidden] { display: none !important; }   /* popup, errors and thank-you panel toggle with the hidden attribute */
.contact .demo-copy { gap: 18px; }
.ct-info { margin: 10px 0 0; display: grid; gap: 14px; width: 100%; max-width: 440px; }
.ct-item { display: grid; gap: 4px; padding: 14px 16px; border-radius: var(--r); border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.05); }
.ct-item dt { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--on-navy-2); }
:lang(ja) .ct-item dt { letter-spacing: .02em; }
.ct-item dt .ico { width: 16px; height: 16px; color: var(--amber); }
.ct-item dd { margin: 0; font-size: 15.5px; line-height: 1.55; color: var(--white); overflow-wrap: anywhere; }
.ct-item a { color: var(--white); text-decoration: underline; text-decoration-color: rgba(255,255,255,.35); text-underline-offset: 4px; }
.ct-item a:hover { text-decoration-color: var(--amber); }
.ct-demo { display: grid; gap: 4px; width: 100%; max-width: 440px; margin-top: 4px; padding: 14px 16px; border-radius: var(--r); border: 1px dashed rgba(255,255,255,.24); color: var(--on-navy); text-decoration: none; transition: border-color .2s, background-color .2s; }
.ct-demo:hover { border-color: var(--amber); background: rgba(255,255,255,.04); }
.ct-demo:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }
.ct-demo-k { font-size: 14.5px; font-weight: 600; color: var(--white); }
.ct-demo-d { font-size: 13.5px; line-height: 1.5; color: var(--on-navy-2); }
.ct-demo-l { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 14px; font-weight: 600; color: var(--amber); }
.ct-demo-l .ico { width: 16px; height: 16px; transition: transform .2s; }
.ct-demo:hover .ct-demo-l .ico { transform: translateX(3px); }
.ct-under { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.ct-count { flex: none; font-size: 12px; color: var(--sh60); font-variant-numeric: tabular-nums; padding-top: 1px; }
.ct-count.is-over { color: var(--red); font-weight: 500; }
.ct-privacy { margin: 0; font-size: 12.5px; line-height: 1.6; color: var(--ink-3); }
.ct-privacy a { color: var(--blue); text-decoration: underline; text-underline-offset: 3px; }
.ct-done-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.ct-done-actions .btn { margin-top: 0; }
.demo-done p b { color: var(--navy); font-weight: 600; overflow-wrap: anywhere; }
.demo-done p a { color: var(--blue); text-decoration: underline; text-underline-offset: 3px; }
.btn-ghost-dark { border: 1px solid var(--sh20); background: var(--white); color: var(--navy); }
.btn-ghost-dark:hover { border-color: var(--navy); }
.btn-ghost-dark:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
@media (max-width: 960px) { .ct-info, .ct-demo { max-width: none; } }
