/* ============================================================
   Waagen Sameie — Editorial Nordic warmth
   Display: Fraunces (variable, self-hosted)
   Body: system-ui sans
   Palette: warm cream paper / ink / forest / sand
   ============================================================ */

@font-face {
  font-family: "Fraunces";
  src: url("resources/fonts/fraunces-latin.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Fraunces";
  src: url("resources/fonts/fraunces-latin-ext.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ----- Tokens ----- */
:root {
  --paper: #f4efe2;
  --paper-soft: #ede6d3;
  --paper-lit: #fbf7ec;
  --ink: #1c1814;
  --ink-soft: #5a5247;
  --ink-mute: #847b6c;
  --rule: #d9cfb5;
  --rule-soft: #e8dfc8;
  --forest: #1f4e4a;
  --forest-dark: #173836;
  --sand: #b8956a;
  --sand-warm: #8e6a3f;
  --rust: #a04b2a;

  --font-display: "Fraunces", "Iowan Old Style", ui-serif, Georgia, serif;
  --font-body: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Helvetica Neue", Arial, sans-serif;

  --max-w: 72rem;
  --max-w-prose: 38rem;

  --shadow-soft: 0 1px 0 var(--rule-soft);
  --shadow-card: 0 10px 30px -18px rgba(28, 24, 20, 0.18),
    0 1px 0 rgba(28, 24, 20, 0.04);

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ----- Reset & base ----- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  /* Paper grain — subtle, no external request */
  background-image:
    radial-gradient(ellipse at top left, rgba(255, 250, 235, 0.55), transparent 60%),
    radial-gradient(ellipse at bottom right, rgba(255, 240, 215, 0.35), transparent 55%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.11 0 0 0 0 0.09 0 0 0 0 0.07 0 0 0 0.045 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-attachment: fixed;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a {
  color: var(--forest);
  text-decoration: none;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
  transition: color 0.18s var(--ease);
}

a:hover {
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--forest);
  outline-offset: 3px;
  border-radius: 2px;
}

::selection {
  background: var(--forest);
  color: var(--paper-lit);
}

/* ----- Layout containers ----- */
.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 3rem);
}

.container-narrow {
  max-width: 52rem;
}

/* ----- Header / nav ----- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem clamp(1.25rem, 4vw, 3rem);
  background: rgba(244, 239, 226, 0.85);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--rule-soft);
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 0.6rem;
  color: var(--ink);
  font-family: var(--font-display);
  font-variation-settings: "opsz" 60, "wght" 500;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  line-height: 1;
}

.brand:hover {
  text-decoration: none;
  color: var(--forest);
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 1.85rem;
  height: 1.85rem;
  border: 1px solid var(--ink);
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 500;
  transform: translateY(0.05em);
}

.site-nav ul {
  display: flex;
  gap: 1.75rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav a {
  position: relative;
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 0.4rem 0;
}

.site-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: -1px;
  height: 1px;
  background: var(--forest);
  transition: right 0.28s var(--ease);
}

.site-nav a:hover {
  color: var(--ink);
  text-decoration: none;
}

.site-nav a:hover::after,
.site-nav a[aria-current="page"]::after {
  right: 0;
}

.site-nav a[aria-current="page"] {
  color: var(--ink);
}

/* Mobile nav */
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.5rem;
  cursor: pointer;
  width: 2.4rem;
  height: 2.4rem;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
}

.nav-toggle span {
  display: block;
  height: 1.5px;
  background: var(--ink);
  transition: transform 0.3s var(--ease), opacity 0.2s;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(0.43rem) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}
.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-0.42rem) rotate(-45deg);
}

@media (max-width: 720px) {
  .nav-toggle {
    display: flex;
  }

  .site-nav ul {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    flex-direction: column;
    gap: 0;
    background: var(--paper-lit);
    border-bottom: 1px solid var(--rule);
    padding: 0.5rem 1.25rem 1rem;
    transform: translateY(-10px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.28s var(--ease), opacity 0.22s;
  }

  .site-nav.is-open ul {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .site-nav li {
    border-bottom: 1px solid var(--rule-soft);
  }
  .site-nav li:last-child {
    border-bottom: none;
  }

  .site-nav a {
    display: block;
    padding: 0.95rem 0;
    font-size: 1.05rem;
  }

  .site-nav a::after {
    display: none;
  }
}

/* ----- Views (hash-routed) ----- */
.view[hidden] {
  display: none;
}

.view {
  animation: viewIn 0.55s var(--ease) both;
}

@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ----- Hero ----- */
.hero {
  position: relative;
  width: 100%;
  height: clamp(28rem, 75vh, 42rem);
  overflow: hidden;
  isolation: isolate;
}

.hero-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 35%;
  filter: saturate(1.05) contrast(1.02);
  animation: heroZoom 18s var(--ease) both;
}

@keyframes heroZoom {
  from {
    transform: scale(1.06);
  }
  to {
    transform: scale(1);
  }
}

.hero-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  padding: clamp(2rem, 6vw, 4.5rem) clamp(1.25rem, 4vw, 3rem);
  background: linear-gradient(
    180deg,
    rgba(28, 24, 20, 0.05) 0%,
    rgba(28, 24, 20, 0.18) 45%,
    rgba(28, 24, 20, 0.72) 100%
  );
  z-index: 1;
}

.hero-content {
  max-width: var(--max-w);
  width: 100%;
  margin: 0 auto;
  color: var(--paper-lit);
}

.eyebrow {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin: 0 0 0.85rem;
}

.hero-content .eyebrow {
  color: rgba(244, 239, 226, 0.75);
  animation: fadeUp 0.9s 0.15s var(--ease) both;
}

.hero h1 {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 144, "wght" 400;
  font-style: italic;
  font-size: clamp(3rem, 9vw, 6.5rem);
  line-height: 0.95;
  letter-spacing: -0.025em;
  margin: 0 0 1.25rem;
  text-wrap: balance;
  animation: fadeUp 0.9s 0.3s var(--ease) both;
}

.hero-lede {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 24, "wght" 400;
  font-size: clamp(1.05rem, 1.5vw, 1.25rem);
  line-height: 1.45;
  max-width: 32rem;
  margin: 0;
  color: rgba(244, 239, 226, 0.92);
  animation: fadeUp 0.9s 0.5s var(--ease) both;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ----- Home cards ----- */
#view-hjem .container {
  padding-top: clamp(3rem, 6vw, 5rem);
  padding-bottom: clamp(4rem, 8vw, 7rem);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: clamp(1.25rem, 3vw, 2.5rem);
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 1.85rem 0 1.5rem;
  border-top: 1px solid var(--ink);
  color: var(--ink);
}

.card:hover {
  text-decoration: none;
}

.card:hover .card-title {
  color: var(--forest);
}

.card-title {
  transition: color 0.2s var(--ease);
}

.card-icon {
  font-size: 1.6rem;
  margin-bottom: 0.85rem;
  filter: grayscale(0.15);
}

.card-title {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 36, "wght" 500;
  font-size: clamp(1.4rem, 2.4vw, 1.75rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0 0 0.6rem;
  color: var(--ink);
}

.card-text {
  font-size: 0.97rem;
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0 0 1.5rem;
  flex: 1;
}

.card-link {
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--forest);
  display: inline-block;
}

.card-link-muted {
  color: var(--ink-mute);
  font-style: italic;
}

/* ----- Page headers (non-home views) ----- */
.page-header {
  padding: clamp(3.5rem, 8vw, 6rem) 0 clamp(2rem, 4vw, 3rem);
  border-bottom: 1px solid var(--rule);
  margin-bottom: clamp(2.5rem, 5vw, 4rem);
}

.page-header h1 {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 144, "wght" 400;
  font-style: italic;
  font-size: clamp(2.75rem, 7vw, 4.5rem);
  line-height: 0.98;
  letter-spacing: -0.022em;
  margin: 0 0 1rem;
  color: var(--ink);
  text-wrap: balance;
}

.page-lede {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 24, "wght" 400;
  font-size: clamp(1.05rem, 1.5vw, 1.2rem);
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 36rem;
  margin: 0;
}

/* ----- Newsletter list (table-of-contents style) ----- */
.newsletter-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.newsletter-loading {
  font-style: italic;
  color: var(--ink-mute);
  padding: 1rem 0;
}

.newsletter-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.25rem;
  align-items: baseline;
  padding: 1.85rem 0;
  border-top: 1px solid var(--rule);
  cursor: pointer;
  transition: background 0.2s var(--ease);
  position: relative;
}

.newsletter-item:last-child {
  border-bottom: 1px solid var(--rule);
}

.newsletter-item:hover {
  background: rgba(255, 247, 230, 0.5);
}

.newsletter-body h3 {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 36, "wght" 500;
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 0.4rem;
  color: var(--ink);
}

.newsletter-snippet {
  font-size: 0.97rem;
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0;
  max-width: 38rem;
}

.newsletter-toggle {
  font-family: var(--font-body);
  font-size: 1.1rem;
  color: var(--ink-soft);
  align-self: start;
  margin-top: 0.35rem;
  width: 1.5rem;
  text-align: center;
  user-select: none;
  line-height: 1;
}

.newsletter-item:hover .newsletter-toggle {
  color: var(--forest);
}

.newsletter-content {
  grid-column: 1 / -1;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.6s var(--ease), padding 0.5s var(--ease),
    opacity 0.5s var(--ease);
  opacity: 0;
}

.newsletter-item.is-open .newsletter-content {
  max-height: 600vh;
  padding: 1.5rem 0 0.5rem;
  opacity: 1;
}

/* Article body — editorial typography */
.article {
  font-family: var(--font-body);
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--ink);
  max-width: 38rem;
}

.article > *:first-child {
  margin-top: 0;
}

.article p {
  margin: 0 0 1.1rem;
  text-wrap: pretty;
}

.article h2 {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 36, "wght" 500;
  font-size: 1.35rem;
  line-height: 1.25;
  letter-spacing: -0.005em;
  margin: 2.2rem 0 0.7rem;
  color: var(--ink);
}

.article h2:first-of-type {
  margin-top: 1.5rem;
}

.article a {
  border-bottom: 1px solid currentColor;
  padding-bottom: 0.05em;
}

.article a:hover {
  text-decoration: none;
  color: var(--forest-dark);
}

.article ul {
  padding-left: 1.25rem;
  margin: 0 0 1.1rem;
}

.article ul li {
  margin-bottom: 0.35rem;
}

.article .article-sig {
  margin-top: 2rem;
  font-style: italic;
  color: var(--ink-soft);
}

/* ----- Dette skjer (events) ----- */
.events-empty {
  font-style: italic;
  color: var(--ink-mute);
  margin: 1rem 0 0;
}

.event-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.event-card {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 1.75rem;
  align-items: start;
  padding: 1.85rem 0;
  border-top: 1px solid var(--rule);
}

.event-card:last-child {
  border-bottom: 1px solid var(--rule);
}

.event-date {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding-top: 0.15rem;
  line-height: 1;
}

.event-day {
  font-family: var(--font-body);
  font-weight: 300;
  font-size: clamp(2.6rem, 5vw, 3.4rem);
  line-height: 0.85;
  color: var(--ink);
  letter-spacing: -0.04em;
  font-variant-numeric: lining-nums tabular-nums;
}

.event-month {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-top: 0.55rem;
}

.event-body {
  min-width: 0;
}

.event-title {
  font-family: var(--font-display);
  font-variation-settings: "opsz" 36, "wght" 500;
  font-size: clamp(1.35rem, 2.5vw, 1.7rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 0.4rem;
  color: var(--ink);
}

.event-meta {
  font-size: 0.92rem;
  color: var(--ink-soft);
  margin: 0 0 1rem;
  letter-spacing: 0.01em;
}

.event-article {
  margin-top: 0.25rem;
}

.event-article p:last-child {
  margin-bottom: 0;
}

/* Past events */
.events-past {
  margin-top: 3rem;
  border-top: 1px solid var(--rule-soft);
  padding-top: 1.5rem;
}

.events-past > summary {
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-mute);
  cursor: pointer;
  list-style: none;
  padding: 0.5rem 0;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.events-past > summary::-webkit-details-marker {
  display: none;
}

.events-past > summary::before {
  content: "›";
  font-size: 1.2rem;
  line-height: 1;
  transition: transform 0.2s var(--ease);
  display: inline-block;
}

.events-past[open] > summary::before {
  transform: rotate(90deg);
}

.events-past > summary:hover {
  color: var(--ink);
}

.event-list-past {
  margin-top: 0.5rem;
}

.event-card-compact {
  padding: 1.25rem 0;
  opacity: 0.78;
}

.event-card-compact .event-day {
  font-size: clamp(1.9rem, 3.5vw, 2.3rem);
}

.event-card-compact .event-title {
  font-size: 1.15rem;
}

.event-card-compact .event-meta {
  margin-bottom: 0;
}

@media (max-width: 480px) {
  .event-card {
    grid-template-columns: 3.5rem 1fr;
    gap: 1rem;
  }
}

/* ----- Vedtekter view ----- */
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-bottom: 2.5rem;
}

.button {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.85rem 1.4rem;
  border-radius: 2px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease),
    color 0.2s var(--ease), border-color 0.2s var(--ease);
  text-decoration: none;
  border: 1px solid transparent;
}

.button:hover {
  text-decoration: none;
  transform: translateY(-1px);
}

.button-primary {
  background: var(--ink);
  color: var(--paper-lit);
}

.button-primary:hover {
  background: var(--forest-dark);
  color: var(--paper-lit);
}

.button-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}

.button-secondary:hover {
  background: var(--ink);
  color: var(--paper-lit);
}

.pdf-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  max-height: 80vh;
  border: 1px solid var(--rule);
  background: var(--paper-lit);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.pdf-frame object,
.pdf-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.pdf-fallback {
  display: grid;
  place-items: center;
  height: 100%;
  margin: 0;
  padding: 2rem;
  text-align: center;
  color: var(--ink-soft);
  font-style: italic;
}

@media (max-width: 640px) {
  .pdf-frame {
    aspect-ratio: 3 / 4;
  }
}

/* ----- Footer ----- */
.site-footer {
  margin-top: clamp(4rem, 8vw, 7rem);
  padding: 2.5rem 0;
  border-top: 1px solid var(--rule);
  font-size: 0.88rem;
  color: var(--ink-mute);
  background: var(--paper-soft);
}

.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
}

.site-footer p {
  margin: 0;
}

.footer-muted {
  font-style: italic;
}

/* ----- Reduced motion ----- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
