/* 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%;
}

.global-date-alert {
  max-width: var(--max-width);
  margin: var(--space-2) auto 0;
  padding: 0.75rem var(--space-2);
  border: 1px solid var(--color-ember);
  border-radius: var(--radius-sm);
  background: #fff3ed;
  color: var(--color-amber-deep);
  font-weight: 600;
}

.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);
}

/* ─── 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;
}

/* ─── 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); }
}
