/* ============================================================
   Toms Arena — delt skjema-stil (v2, runde 2026-10)
   ------------------------------------------------------------
   Brukes av kontakt-tom.html (timeforespørsel til Tom) og
   akademi.html (jobbsøknad med vedlegg). Lastes etter
   shared/side-base.css; tokens fra shared/v2.css (--forest-*,
   --sage*) brukes med reserveverdier, så fila tåler å lastes
   før v2.css.

   v2: synlige etiketter i Inter over feltet (ikke mono i 10px),
   runde felt (14px), 52px høye felt og knapp, «riktig»-merke når
   et felt er godkjent, spinner i knappen mens skjemaet sendes og
   en kvittering med hake når det er sendt. Valideringen på blur
   ligger i shared/forms.js.

   TILGJENGELIGHET — regler denne fila forutsetter av markupen:
   · hvert felt har en <label for> som peker på feltets id
   · feilmeldingen ligger i <p class="tf-err" id="…-err">, og
     feltet peker på den med aria-describedby
   · feilmeldingen er tom og hidden til den faktisk vises
   · ingenting styres av farge alene: feil får rød tekst, rød kant
     og et ikon; godkjent får en hake
   ============================================================ */

.tf-form { max-width: 640px; }

.tf-row { margin-bottom: 22px; }
.tf-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 22px;
}
.tf-row-2 .tf-row { margin-bottom: 0; }
@media (max-width: 560px) {
  .tf-row-2 { grid-template-columns: 1fr; gap: 22px; }
}

.tf-label {
  display: block;
  font-family: 'Poppins', 'Inter', 'Inter fb', sans-serif;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink, #15191A);
  margin-bottom: 8px;
}
.tf-label .tf-opt {
  font-weight: 400;
  color: var(--muted, #5B605A);
}

.tf-input,
.tf-textarea,
.tf-file {
  width: 100%;
  box-sizing: border-box;
  font-family: 'Poppins', 'Inter', 'Inter fb', sans-serif;
  font-size: 16px; /* 16px hindrer at iOS zoomer inn ved fokus */
  line-height: 1.5;
  color: var(--ink, #15191A);
  background-color: #fff;
  border: 1.5px solid rgba(21, 25, 26, .16);
  border-radius: 14px;
  padding: 13px 16px;
  min-height: 52px;
  transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}
.tf-input::placeholder,
.tf-textarea::placeholder { color: #6F746D; }
.tf-textarea { min-height: 140px; resize: vertical; }

.tf-input:hover,
.tf-textarea:hover { border-color: rgba(21, 25, 26, .32); }

.tf-input:focus,
.tf-textarea:focus,
.tf-file:focus {
  outline: none;
  border-color: var(--forest-800, #3B5541);
  box-shadow: 0 0 0 4px var(--sage-2, #DCEBD6);
}

/* Godkjent: en liten hake inne i feltet. Settes av forms.js når et
   felt man har vært innom stemmer. */
.tf-input.tf-valid {
  border-color: rgba(74, 102, 80, .55);
  padding-inline-end: 46px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233E6B47' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.2 4.2L19 7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 18px 18px;
  background-position: right 16px center;
}
html[dir="rtl"] .tf-input.tf-valid { background-position: left 16px center; }

.tf-hint {
  margin: 8px 0 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--muted, #5B605A);
}

/* ---- Feilmelding ved feltet ---- */
.tf-err {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 8px 0 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: #8C2E23;
}
.tf-err::before {
  content: "!";
  flex: none;
  display: inline-grid; place-items: center;
  width: 18px; height: 18px; margin-top: 1px;
  border-radius: 50%;
  background: #A3372B; color: #fff;
  font-size: 11px; font-weight: 700;
}
.tf-err[hidden] { display: none; }

.tf-input[aria-invalid="true"],
.tf-textarea[aria-invalid="true"],
.tf-file[aria-invalid="true"] {
  border-color: #A3372B;
  background-color: #FDF6F5;
}
.tf-input[aria-invalid="true"]:focus,
.tf-textarea[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px rgba(163, 55, 43, .14); }

/* ---- Filopplasting ---- */
.tf-file {
  padding: 8px 10px;
  background-color: var(--paper-2, #F3F5F2);
  border-style: dashed;
  cursor: pointer;
}
.tf-file::file-selector-button {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  margin-inline-end: 14px;
  min-height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--forest-950, #2A4A31);
  color: #fff;
  cursor: pointer;
  transition: background-color .2s ease;
}
.tf-file::file-selector-button:hover { background: var(--forest-800, #3B5541); }

/* ---- Merknad over skjemaet (helseopplysninger / personvern) ---- */
.tf-notice {
  position: relative;
  border-radius: 20px;
  background: var(--sage-2, #DCEBD6);
  padding: 18px 20px 18px 62px;
  margin: 0 0 28px;
  max-width: 640px;
}
.tf-notice::before {
  content: "i";
  position: absolute;
  inset-inline-start: 18px; top: 18px;
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--forest-950, #2A4A31); color: #fff;
  font-family: 'TA Serif', 'Fraunces', Georgia, serif; font-style: italic; font-size: 16px;
}
html[dir="rtl"] .tf-notice { padding: 18px 62px 18px 20px; }
.tf-notice[hidden] { display: none; }
.tf-notice h2,
.tf-notice .tf-notice-title {
  font-family: 'Poppins', 'Inter', 'Inter fb', sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink, #15191A);
  margin: 4px 0 6px;
}
.tf-notice p {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink-2, #2D3330);
}
.tf-notice p + p { margin-top: 6px; }
.tf-notice a {
  color: var(--ink, #15191A);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-word;
}
.tf-notice a:hover { color: var(--forest-800, #3B5541); }

/* ---- Honeypot ----
   Skjult for øyet OG for skjermlesere/tastatur. */
.tf-hp {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---- Personverntekst over sendeknappen ----
   Informasjon, ikke en avkrysning: kontaktskjemaet bygger på
   berettiget interesse, ikke samtykke (personvern.html). Lenken
   står med understrek og egen fokusring, og flata rundt er stor nok
   til å treffe på mobil. */
.tf-consent {
  position: relative;
  margin: 6px 0 0;
  padding: 14px 16px 14px 46px;
  border-radius: 16px;
  background: var(--paper-2, #F3F5F2);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-2, #2D3330);
}
.tf-consent::before {
  content: "";
  position: absolute;
  inset-inline-start: 16px; top: 15px;
  width: 18px; height: 18px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233E6B47' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='11' width='14' height='9' rx='2.5'/%3E%3Cpath d='M8 11V8a4 4 0 0 1 8 0v3'/%3E%3C/svg%3E") center / 18px no-repeat;
}
.tf-consent a {
  color: var(--ink, #15191A);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.tf-consent a:hover { color: var(--green, #2A4A31); }
.tf-consent a:focus-visible { outline: 2px solid var(--forest-800, #3B5541); outline-offset: 2px; border-radius: 4px; }
html[dir="rtl"] .tf-consent { padding: 14px 46px 14px 16px; }
.tf-consent + .tf-actions { margin-top: 22px; }

/* ---- Innsending ---- */
.tf-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 30px;
}
.tf-form .tf-submit {
  position: relative;
  min-height: 52px;
  padding: 0 9px 0 26px;
  border-radius: 999px;
  border: 0;
  background: var(--forest-950, #2A4A31);
  color: #fff;
  font-size: 15.5px;
  font-weight: 600;
  gap: 14px;
  cursor: pointer;
  transition: background-color .25s ease, transform .25s ease;
}
.tf-form .tf-submit:hover { background: var(--forest-800, #3B5541); }
.tf-form .tf-submit:active { transform: translateY(1px); }
.tf-form .tf-submit:focus-visible { outline: 2px solid var(--forest-800, #3B5541); outline-offset: 3px; }
/* Pila i en hvit sirkel. Markupen har pila som et <span aria-hidden>.
   .btn-arrow::after (headerens pil) skal ikke tegnes her i tillegg. */
.tf-form .tf-submit::after { content: none !important; }
.tf-form .tf-submit > span[aria-hidden] {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: #fff; color: var(--ink, #15191A);
  font-size: 15px;
  box-sizing: border-box;
  transition: transform .3s ease;
}
.tf-form .tf-submit:hover > span[aria-hidden] { transform: translateX(2px); }
.tf-form .tf-submit[disabled] { cursor: progress; opacity: 1; }
/* Laster: pila blir en spinner. */
.tf-form .tf-submit.is-busy > span[aria-hidden] {
  color: transparent;
  background: transparent;
  border: 2px solid rgba(255, 255, 255, .3);
  border-top-color: #fff;
  animation: tfSpin .8s linear infinite;
}
@keyframes tfSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .tf-form .tf-submit.is-busy > span[aria-hidden] { animation: none; border-top-color: rgba(255, 255, 255, .3); }
}
@media (max-width: 560px) {
  .tf-actions .tf-submit { width: 100%; justify-content: space-between; }
}

/* Statuslinja er aria-live, så teksten leses opp når den endres. */
.tf-status {
  margin: 18px 0 0;
  max-width: 640px;
  font-size: 14.5px;
  line-height: 1.6;
  padding: 14px 18px;
  border: 1px solid rgba(21, 25, 26, .12);
  border-radius: 16px;
}
.tf-status[hidden] { display: none; }
.tf-status-ok {
  border-color: transparent;
  background: var(--sage-2, #DCEBD6);
  color: var(--ink, #15191A);
}
.tf-status-err {
  border-color: rgba(163, 55, 43, .35);
  background: #FDF6F5;
  color: #8C2E23;
}
.tf-status a { color: inherit; font-weight: 600; }

/* Kvitteringen som erstatter skjemaet etter vellykket innsending. */
.tf-thanks {
  max-width: 640px;
  border-radius: 24px;
  background: var(--sage-2, #DCEBD6);
  padding: 30px 30px 32px;
}
.tf-thanks::before {
  content: "";
  display: block;
  width: 52px; height: 52px; border-radius: 50%;
  margin-bottom: 18px;
  background: var(--forest-950, #2A4A31) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.2 4.2L19 7'/%3E%3C/svg%3E") center / 24px no-repeat;
}
.tf-thanks[hidden] { display: none; }
.tf-thanks:focus { outline: none; }
.tf-thanks:focus-visible { outline: 2px solid var(--forest-800, #3B5541); outline-offset: 4px; }
.tf-thanks h2 {
  font-family: 'TA Serif', 'Fraunces', 'Fraunces fb', Georgia, serif;
  font-weight: 400;
  font-size: clamp(24px, 2.6vw, 32px);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
  color: var(--ink, #15191A);
}
.tf-thanks p { margin: 0; font-size: 15.5px; line-height: 1.65; color: var(--ink-2, #2D3330); }
@media (prefers-reduced-motion: no-preference) {
  .tf-thanks.is-shown { animation: tfIn .5s cubic-bezier(.2, .8, .2, 1) both; }
  .tf-thanks.is-shown::before { animation: tfPop .6s cubic-bezier(.2, .8, .2, 1) .1s both; }
  @keyframes tfIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
  @keyframes tfPop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
}

/* Reserveknappen under statuslinja når et kall til /api/send feiler.
   Bevisst dempet: en utvei, ikke sidens hovedhandling. */
.tf-fallback {
  display: inline-flex;
  align-items: center;
  margin-top: 12px;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid rgba(21, 25, 26, .2);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2, #2D3330);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background-color .15s ease;
}
.tf-fallback:hover {
  border-color: var(--forest-800, #3B5541);
  color: var(--ink, #15191A);
  background: var(--sage-2, #DCEBD6);
}

/* Skjemakortet: hvit flate med myke hjørner rundt skjemaet. */
.tf-card {
  background: #fff;
  border: 1px solid rgba(15, 36, 24, .08);
  border-radius: 28px;
  box-shadow: 0 1px 2px rgba(15, 36, 24, .06), 0 18px 48px -18px rgba(15, 36, 24, .2);
  padding: clamp(22px, 4vw, 44px);
}
.tf-card .tf-form, .tf-card .tf-notice, .tf-card .tf-thanks { max-width: none; }
@media (max-width: 560px) {
  .tf-card { border-radius: 22px; padding: 22px 18px 26px; }
}

/* ---- Valgt fil (runde 20): filnavn, størrelse og «Fjern» ---- */
.tf-file-chosen {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  padding: 8px 8px 8px 14px;
  border-radius: 12px;
  background: var(--sage-2, #DCEBD6);
  font-size: 14.5px;
  line-height: 1.4;
  color: var(--ink, #15191A);
}
.tf-file-chosen[hidden] { display: none; }
.tf-file-name { min-width: 0; overflow-wrap: anywhere; font-weight: 500; }
.tf-file-remove {
  flex: none;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(15, 36, 24, .28);
  border-radius: 999px;
  background: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink, #15191A);
  cursor: pointer;
}
.tf-file-remove:hover { border-color: var(--ink, #15191A); }
.tf-file-remove:focus-visible { outline: 2px solid var(--forest-800, #3B5541); outline-offset: 2px; }
