/* =========================================================
   ElektroNyheter – STIL
   Farger og tider hentes fra config.css.
   ========================================================= */

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  font-size: var(--font-size-base);
  scroll-padding-top: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
  color-scheme: light dark;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; border-radius: 2px; }

.grid-bg {
  background-image:
    linear-gradient(var(--color-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--color-grid) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* ---------- Intro ---------- */
.intro {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 0 1.5rem;
  background-color: var(--color-bg);
  transition: opacity var(--intro-fade-time) ease, visibility var(--intro-fade-time);
}
.intro.hidden { opacity: 0; visibility: hidden; }

.intro-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.25rem;
  transition: transform var(--intro-fade-time) ease;
}
.intro.hidden .intro-inner { transform: scale(0.96); }

.intro h1 {
  font-size: var(--font-size-intro);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 0.95;
}

.trace { width: 100%; height: auto; overflow: visible; }

.trace path {
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: draw var(--intro-draw-time) ease-out 0.05s forwards;
}
.trace circle {
  fill: var(--color-bg);
  stroke: var(--color-accent-dark);
  stroke-width: 4;
  opacity: 0;
  animation: pad 0.08s ease-out forwards;
}
.trace .start { animation-delay: 0s; }
.trace .end { animation-delay: calc(var(--intro-draw-time) - 0.03s); }

@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pad { to { opacity: 1; } }

/* ---------- Siden ---------- */
.site { opacity: 0; transition: opacity var(--intro-fade-time) ease; }
.site.visible { opacity: 1; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-line);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner {
  max-width: var(--page-width);
  margin: 0 auto;
  height: var(--topbar-height);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 800;
  font-size: var(--font-size-logo);
  letter-spacing: -0.03em;
  white-space: nowrap;
}
.logo svg { width: 30px; height: 18px; flex-shrink: 0; }
.logo path { fill: none; stroke: var(--color-accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.logo circle { fill: var(--color-surface); stroke: var(--color-accent-dark); stroke-width: 2.5; }

.nav {
  display: flex;
  gap: 1.4rem;
  overflow-x: auto;
  scrollbar-width: none;
  font-size: 0.98rem;
  font-weight: 500;
  color: var(--color-muted);
}
.nav::-webkit-scrollbar { display: none; }
.nav a { white-space: nowrap; padding: 0.4rem 0; border-bottom: 2px solid transparent; }
.nav a:hover { color: var(--color-text); }
.nav a[aria-current="page"] { color: var(--color-text); border-bottom-color: var(--color-accent); }

main {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

.thumb {
  display: block;
  background-color: var(--color-image);
  background-image:
    linear-gradient(var(--color-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--color-grid) 1px, transparent 1px);
  background-size: 16px 16px;
  border-radius: var(--radius);
}

.category { color: var(--color-accent); font-weight: 700; font-size: 0.92rem; }
.meta { color: var(--color-muted); font-size: 0.88rem; }

/* Hovedsak */
.lead {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 2rem;
  align-items: center;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--color-line);
}
.lead .thumb { aspect-ratio: 16 / 10; border-radius: var(--radius-large); }
.lead-text { display: flex; flex-direction: column; gap: 0.75rem; }
.lead h2 {
  font-size: clamp(1.7rem, 3.4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.08;
}
.lead p { color: var(--color-muted); font-size: 1.08rem; max-width: 46ch; }
.lead a:hover h2 { text-decoration: underline; text-decoration-color: var(--color-accent); text-underline-offset: 5px; }

/* Siste nytt */
.latest { padding-top: 2.25rem; }
.latest > h2 { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.015em; margin-bottom: 1.25rem; }
.articles { list-style: none; display: grid; grid-template-columns: 1fr 1fr; column-gap: 2.5rem; }
.articles li { border-top: 1px solid var(--color-line); }
.articles a {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 1rem;
  padding: 1.1rem 0;
  align-items: start;
}
.articles .thumb { aspect-ratio: 4 / 3; }
.articles h3 { font-size: 1.08rem; font-weight: 700; line-height: 1.25; margin: 0.15rem 0 0.35rem; }
.articles a:hover h3 { text-decoration: underline; text-decoration-color: var(--color-accent); text-underline-offset: 4px; }

footer {
  border-top: 1px solid var(--color-line);
  padding: 1.5rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
  text-align: center;
  color: var(--color-muted);
  font-size: 0.88rem;
}

/* ---------- Mobil ---------- */
@media (max-width: 820px) {
  .lead { grid-template-columns: 1fr; gap: 1.25rem; }
  .articles { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .topbar-inner { height: auto; flex-direction: column; align-items: flex-start; gap: 0.25rem; padding-top: 0.75rem; padding-bottom: 0.4rem; }
  .nav { width: 100%; }
  .articles a { grid-template-columns: 88px 1fr; }
}

/* ---------- Redusert bevegelse ---------- */
@media (prefers-reduced-motion: reduce) {
  .trace path { animation: none; stroke-dashoffset: 0; }
  .trace circle { animation: none; opacity: 1; }
  .intro, .intro-inner, .site { transition-duration: 0.01s; }
}
