/* base.css — CSS-variabler, reset, typografi, gemensamma komponenter */

/* ─── Google Fonts ────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

/* ─── Variabler ───────────────────────────────────────────────────────── */
:root {
  /* Primärfärger — höstig rost/terrakotta (från te-logotype.svg) */
  --color-rust-deep:  #6B2E0E;
  --color-rust:       #B2571F;
  --color-rust-light: #FCE7CC;

  /* Accentfärger — varm bärnsten */
  --color-amber-deep:   #9C5B0E;
  --color-amber:        #F0923D;
  --color-amber-light:  #FDECD1;
  --color-ember:        #D8592E;

  /* Neutrala */
  --color-cream:       #FDFAF4;
  --color-gray-light:  #F1EFE8;
  --color-text:        #2A1F17;
  --color-text-muted:  #7A6F63;
  --color-placeholder: #BBB0A0;

  /* Linjer */
  --border-rust:      0.5px solid #F0C88F;
  --border-amber:     0.5px solid #F6CE8E;

  /* Typografi */
  --font-heading: Georgia, 'Times New Roman', serif;
  --font-body:    'DM Sans', system-ui, -apple-system, sans-serif;

  /* Storlekar — mobile first, alltid ≥ 16px i formulärfält (förhindrar iOS-zoom) */
  --text-xs:   0.75rem;   /* 12px */
  --text-sm:   0.875rem;  /* 14px */
  --text-base: 1rem;      /* 16px */
  --text-lg:   1.125rem;  /* 18px */
  --text-xl:   1.5rem;    /* 24px */
  --text-2xl:  2rem;      /* 32px */

  /* Spacing */
  --space-1: 0.5rem;    /* 8px */
  --space-2: 1rem;      /* 16px */
  --space-3: 1.5rem;    /* 24px */
  --space-4: 2rem;      /* 32px */
  --space-5: 2.5rem;    /* 40px */
  --space-6: 3rem;      /* 48px */

  /* Hörnradier */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  /* Layout */
  --max-width:   680px;
  --nav-height:  64px;
  --page-pad:    var(--space-2);
}

/* ─── Reset ───────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-cream);
  /* Plats för fast bottom-nav + iOS safe-area */
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  min-height: 100dvh;
  overflow-x: hidden;
}

img,
video {
  max-width: 100%;
  display: block;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
}

a {
  color: inherit;
  text-decoration: none;
}

ul {
  list-style: none;
}

/* ─── Typografi ───────────────────────────────────────────────────────── */
h1, h2, h3 {
  font-family: var(--font-heading);
  line-height: 1.25;
  color: var(--color-rust-deep);
}

h1 { font-size: var(--text-xl); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-base); font-weight: 600; }

p { margin-bottom: var(--space-2); }
p:last-child { margin-bottom: 0; }

/* ─── Layout ──────────────────────────────────────────────────────────── */
.fas {
  min-height: calc(100dvh - var(--nav-height));
  width: 100%;
}

.container {
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--page-pad);
}

.view {
  padding: var(--space-4) var(--page-pad);
  max-width: var(--max-width);
  margin-inline: auto;
}

/* ─── Knappar ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-height: 44px;          /* touch target */
  padding: 0.75rem var(--space-3);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  cursor: pointer;
  border: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--color-rust);
  color: #fff;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-secondary {
  background: transparent;
  color: var(--color-rust);
  border: 1.5px solid var(--color-rust);
}

.btn-accent {
  background: var(--color-amber);
  color: #fff;
}

.btn-full {
  display: flex;
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.btn-ghost {
  background: transparent;
  color: var(--color-rust);
  border: 1.5px solid var(--color-rust);
}

.btn-ghost:hover {
  opacity: 0.8;
}

.btn-sm {
  min-height: 36px;
  padding: 0.4rem var(--space-3);
  font-size: var(--text-sm);
}

/* ─── Sektionsrubrik ──────────────────────────────────────────────────── */
.section-header {
  margin-bottom: var(--space-4);
}

.section-header h2 {
  margin-bottom: var(--space-1);
}

.section-desc {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-bottom: 0;
}

/* ─── Formulär ────────────────────────────────────────────────────────── */
.field {
  margin-bottom: var(--space-3);
}

.field label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-rust-deep);
  margin-bottom: var(--space-1);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field-optional {
  font-weight: 400;
  text-transform: none;
  color: var(--color-text-muted);
  letter-spacing: 0;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  height: 48px;           /* touch friendly */
  padding: 0 var(--space-2);
  border: var(--border-rust);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 1rem;        /* exakt 16px — förhindrar iOS-zoom */
  color: var(--color-rust-deep);
  background: #fff;
  appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field textarea {
  height: auto;
  padding: var(--space-2);
  resize: vertical;
  min-height: 80px;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--color-placeholder);
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--color-rust);
  box-shadow: 0 0 0 2px var(--color-rust-light);
}

.field input[aria-invalid='true'],
.field textarea[aria-invalid='true'] {
  border-color: var(--color-ember);
}

.field-hint {
  margin-top: 6px;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-style: italic;
}

/* ─── Felmeddelanden ──────────────────────────────────────────────────── */
.field-error {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  color: var(--color-ember);
  font-size: var(--text-sm);
}

.api-error {
  padding: var(--space-2);
  background: #fff0ec;
  border: 1px solid var(--color-ember);
  border-radius: var(--radius-sm);
  color: var(--color-ember);
  font-size: var(--text-sm);
  margin-bottom: var(--space-3);
}

/* ─── Infokort ────────────────────────────────────────────────────────── */
.info-section {
  background: #fff;
  border: var(--border-rust);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}

.info-section h3 {
  margin-bottom: var(--space-1);
  font-size: var(--text-base);
}

.info-section p,
.info-section ul {
  color: var(--color-text);
  font-size: var(--text-base);
}

/* ─── Tips-panel på ljus Info-bakgrund (klon av fas 1-teasern) ─────────── */
.fas1-tip.fas-info-tip {
  border-color: rgba(178, 87, 31, 0.35);
  background: var(--color-amber-light);
}

.fas-info-tip .fas1-tip-trigger {
  color: var(--color-rust-deep);
}

.fas-info-tip .fas1-tip-trigger:hover {
  background: rgba(178, 87, 31, 0.06);
}

.fas-info-tip .fas1-tip-icon {
  stroke: var(--color-rust);
}

.fas-info-tip.fas1-tip[open] .fas1-tip-icon {
  filter: drop-shadow(0 0 6px rgba(178, 87, 31, 0.45));
}

.fas-info-tip.fas1-tip[open] .fas1-tip-trigger {
  border-bottom-color: rgba(178, 87, 31, 0.25);
}

.fas-info-tip .fas1-tip-content {
  color: var(--color-text);
}

.fas-info-tip .fas1-tip-os-title {
  color: var(--color-rust-deep);
}

/* ─── Hälsningsvägg ───────────────────────────────────────────────────── */
.halsningsvagg {
  margin-top: var(--space-4);
}

.halsningsvagg--fas4 {
  padding: 0 1.25rem;
  margin-top: 0;
  margin-bottom: var(--space-3);
}

.halsningsvagg-title {
  margin-bottom: var(--space-2);
}

.halsningsvagg-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.halsningsvagg-card {
  background: #fff;
  border: var(--border-rust);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
}

.halsningsvagg-text {
  font-size: var(--text-base);
  color: var(--color-text);
  margin-bottom: 4px;
  white-space: pre-wrap;
  word-break: break-word;
}

.halsningsvagg-author {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: 0;
  text-align: right;
}

.halsningsvagg-empty {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-style: italic;
  margin-bottom: 0;
}

/* ─── Bottom Navigation ───────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #fff;
  border-top: var(--border-rust);
  display: flex;
  align-items: stretch;
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(39, 80, 10, 0.06);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;       /* touch target */
  padding: var(--space-1) 0;
  color: var(--color-text-muted);
  font-size: 0.6875rem;   /* 11px */
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: color 0.15s;
  cursor: pointer;
  border: none;
  background: none;
}

.nav-item[aria-selected='true'],
.nav-item.active {
  color: var(--color-rust);
}

.nav-icon {
  width: 24px;
  height: 24px;
  stroke-width: 1.75;
  flex-shrink: 0;
}

/* ─── Admin-genväg (Torgny/Erica) ─────────────────────────────────────── */
.host-admin-fab {
  position: fixed;
  right: var(--space-2);
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + var(--space-2));
  z-index: 101;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-rust-deep);
  color: #fff;
  font-size: 1.25rem;
  line-height: 1;
  text-decoration: none;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.15s;
}

.host-admin-fab:active {
  transform: scale(0.94);
}

/* ─── Fasväljare (gäster: nuvarande + tidigare · Torgny/Erica: alla) ──── */
.phase-switcher {
  position: sticky;
  top: 0;
  z-index: 150;
  background: var(--color-rust-deep);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  /* Låt inte statusfält/notch täcka eller göra flikarna oklickbara */
  padding-top: env(safe-area-inset-top, 0px);
}

.phase-switcher-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 6px var(--space-2);
  background: var(--color-amber-deep);
  color: #fff;
  font-size: var(--text-xs);
  text-align: center;
}

.phase-switcher-reset {
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font-size: var(--text-xs);
  padding: 2px 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.phase-switcher-tabs {
  display: flex;
  overflow-x: auto;
  gap: 6px;
  padding: 8px var(--space-2);
  -webkit-overflow-scrolling: touch;
}

.phase-switcher-tab {
  flex: 0 0 auto;
  position: relative;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  font-size: var(--text-xs);
  font-family: var(--font-body);
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.phase-switcher-tab--active {
  background: #fff;
  color: var(--color-rust-deep);
  font-weight: 600;
}

.phase-switcher-tab--real::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-amber);
}

.phase-switcher-tab--active.phase-switcher-tab--real::after {
  background: var(--color-ember);
}

/* ─── Utility ─────────────────────────────────────────────────────────── */
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ─── Desktop ─────────────────────────────────────────────────────────── */
@media (min-width: 680px) {
  :root {
    --page-pad: var(--space-4);
  }

  h1 { font-size: var(--text-2xl); }
  h2 { font-size: var(--text-xl); }
}
