/* --- Importer Fonter --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&family=Playfair+Display:wght@700&display=swap');

/*
==========================================
  CSS Variabler (Roter)
==========================================
*/
:root {
  /* Fonter */
  --font-body: 'Inter', sans-serif;
  --font-display: 'Playfair Display', serif;

  /* --- Ny Fargepalett --- */
  --palette-autumn-ember: #b45309;
  /* Primær */
  --palette-burnt-caramel: #bd6829;
  /* Hover/Valgt */
  --palette-shadow-grey: #292524;
  /* Mørkest */
  --palette-gunmetal: #3f3f46;
  /* Sekundær mørk */
  --palette-white: #fefefe;
  /* Lysest */

  /* --- Funksjonelle Variabler --- */
  --color-primary: var(--palette-autumn-ember);
  --color-primary-hover: var(--palette-burnt-caramel);

  --color-bg-page: var(--palette-white);
  --color-bg-card: #ffffff;
  --color-bg-section: #f5f5f4;
  /* stone-100 */
  --color-bg-white: var(--palette-white);
  --color-bg-header: rgba(255, 255, 255, 0.9);
  --color-bg-footer: var(--palette-shadow-grey);

  --color-text-main: var(--palette-shadow-grey);
  --color-text-muted: #57534e;
  /* stone-600 */
  --color-text-inverse: var(--palette-white);
  --color-text-base: #1c1917;
  --color-text-footer: #d6d3d1;
  /* stone-300 */

  --color-border: #d6d3d1;
  --color-error: #dc2626;

  /* Annet */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --border-radius-sm: 0.375rem;
  --border-radius-md: 0.5rem;
  --border-radius-lg: 0.75rem;
  --border-radius-full: 9999px;

  --transition-all: all 0.2s ease-in-out;
}

/* --- Dark Mode Overrides --- */
[data-theme="dark"] {
  --color-bg-page: var(--palette-shadow-grey);
  --color-bg-card: var(--palette-gunmetal);
  --color-bg-section: #27272a;
  /* zinc-800 */
  --color-bg-header: rgba(41, 37, 36, 0.9);

  --color-text-main: var(--palette-white);
  --color-text-muted: #a1a1aa;
  /* zinc-400 */
  --color-text-inverse: var(--palette-white);

  --color-border: #52525b;
  /* zinc-600 - Increased contrast */
  --color-bg-white: var(--palette-shadow-grey);
  /* Changed to match page bg so cards stand out */

  --color-bg-input: #18181b;
  /* zinc-900 - Darker background for inputs in dark mode */
  --color-bg-footer: #171717;
  /* Darker than page bg (#292524) */
}

/* Ensure broad readability in dark mode for dynamic content */
[data-theme="dark"] p,
[data-theme="dark"] .feed-item-content,
[data-theme="dark"] .feed-item-content *,
[data-theme="dark"] #documents-list-container,
[data-theme="dark"] #documents-list-container * {
  color: var(--color-text-main) !important;
}

/* --- Theme Helpers --- */
[data-theme="dark"] .logo-light-only {
  display: none !important;
}

[data-theme="light"] .logo-dark-only {
  display: none !important;
}

[data-theme="dark"] .logo-dark-only {
  display: block !important;
}

.hidden {
  display: none !important;
}

/*
==========================================
  Nullstilling (Reset) og Basis
==========================================
*/
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  color: var(--color-text-main);
  background-color: var(--color-bg-page);
  line-height: 1.6;
  overflow-x: hidden;
  /* Prevent horizontal scroll from fixed menu */
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: var(--transition-all);
}

a:hover {
  color: var(--color-primary-hover);
}

ul,
ol {
  list-style-position: inside;
}

/*
==========================================
  Hjelpeklasser (Utility Classes)
==========================================
*/
.container {
  width: 100%;
  /* max-width: 1100px;  <-- FJERNET DENNE */
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.5rem;
  /* 24px */
  padding-right: 1.5rem;
  /* 24px */
}

.section {
  padding-top: 5rem;
  /* 80px */
  padding-bottom: 5rem;
  /* 80px */
}

.section-bg-medium {
  background-color: var(--color-bg-section);
}

.section-bg-white {
  background-color: var(--color-bg-white);
}

.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

/* Skjuler elementer */
.hidden {
  display: none !important;
}

/*
==========================================
  Typografi
==========================================
*/
h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  color: var(--color-text-main);
  font-weight: 700;
  margin-bottom: 1rem;
}

h1 {
  font-size: 3rem;
  /* 48px */
  margin-bottom: 1rem;
}

h2 {
  font-size: 2.25rem;
  /* 36px */
  margin-bottom: 1.5rem;
}

h3 {
  font-size: 1.5rem;
  /* 24px */
}

p {
  margin-bottom: 1rem;
  font-size: 1rem;
  color: var(--color-text-muted);
}

/* Større avsnitt-tekst */
.text-lg {
  font-size: 1.125rem;
  /* 18px */
  line-height: 1.7;
}

/*
==========================================
  Knapper
==========================================
*/
.button {
  display: inline-block;
  font-family: var(--font-body);
  font-weight: 700;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--border-radius-full);
  cursor: pointer;
  transition: var(--transition-all);
  text-align: center;
  font-size: 0.875rem;
  /* 14px */
}

.button:hover {
  transform: scale(1.05);
  background-color: var(--color-primary-hover);
}

/* Primær knapp (Oransje) */
.button-primary {
  background-color: var(--color-primary);
  color: var(--color-text-inverse);
}

.button-primary:hover {
  background-color: var(--color-primary-hover);
  color: var(--color-text-inverse);
}

/* Sekundær knapp (Nå lysere/hvit-ish i lys modus) */
.button-secondary {
  background-color: var(--color-bg-white);
  color: var(--color-text-main);
  border: 2px solid var(--color-border);
}

.button-secondary:hover {
  background-color: var(--color-bg-section);
  border-color: var(--color-primary);
  color: var(--color-text-main);
}

/* Større knapp */
.button-lg {
  padding: 0.75rem 2rem;
  font-size: 1.125rem;
  /* 18px */
}

/* Logg ut-knapp (spesial) */
#logout-button,
#mobile-logout-button {
  background-color: var(--color-text-muted);
  color: white;
}

#logout-button:hover,
#mobile-logout-button:hover {
  background-color: var(--palette-shadow-grey);
}

/* 
==========================================
  Dark Mode Toggle Button
==========================================
*/
.theme-toggle {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 1000;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: flex !important;
  align-items: center;
  justify-content: center;
  border: none;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: var(--transition-all);
}

.theme-toggle:hover {
  transform: scale(1.1) rotate(15deg);
  background: var(--color-primary-hover);
  box-shadow: var(--shadow-xl);
}

/* Skjul "Bytt tema" tekst på floating knapp */
.theme-toggle span {
  display: none;
}

@media (max-width: 768px) {
  .theme-toggle {
    bottom: 1.5rem;
    right: 1.5rem;
    width: 45px;
    height: 45px;
  }
}

/*
==========================================
  Skjema (Forms)
==========================================
*/
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  font-weight: 500;
  color: var(--color-secondary);
  margin-bottom: 0.5rem;
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
  font-family: var(--font-body);
  font-size: 1rem;
  transition: var(--transition-colors);
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(180, 83, 9, 0.2);
  /* Ring-effekt */
}

.form-input,
.form-textarea {
  background-color: var(--color-bg-input, var(--color-bg-card));
  color: var(--color-text-main);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--color-text-muted);
  opacity: 1;
  /* For Firefox */
}

.form-textarea {
  resize: vertical;
  min-height: 120px;
}

.form-error {
  color: var(--color-error);
  font-size: 0.875rem;
  text-align: center;
  margin-top: 1rem;
}

/*
==========================================
  Header & Navigasjon
==========================================
*/
.main-header {
  background-color: var(--color-bg-header);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.3s ease;
}

.main-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  /* 12px */
  text-decoration: none;
}

.logo-img {
  height: 3rem;
  /* 48px */
  width: 3rem;
  /* 48px */
  border-radius: var(--border-radius-full);
  object-fit: cover;
}

.logo-text {
  font-size: 1.25rem;
  /* 20px */
  font-weight: 600;
  color: var(--color-text-main);
}

/* Desktop-meny */
.nav-menu-desktop {
  display: none;
  /* Skjult på mobil */
  align-items: center;
  gap: 1.5rem;
  /* 24px */
}

.nav-link {
  color: var(--color-text-muted);
  transition: var(--transition-all);
  font-weight: 500;
}

.nav-link:hover {
  color: var(--color-primary-dark);
}

/* Aktiv lenke (og medlemslenke) */
.nav-link-active {
  color: var(--color-primary);
  font-weight: 600;
}

/* Mobilmeny-knapp */
.mobile-menu-button {
  display: block;
  /* Vises på mobil */
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-main);
  z-index: 101;
  transition: var(--transition-all);
}

.mobile-menu-button:hover {
  color: var(--color-primary);
  transform: scale(1.1);
}

.mobile-menu-button svg {
  width: 1.5rem;
  height: 1.5rem;
  display: block;
}

/* Mobilmeny (Premium Overlay) */
.nav-menu-mobile {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  height: 100vh;
  background-color: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 2rem;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 0;
  pointer-events: none;
}

[data-theme="dark"] .nav-menu-mobile {
  background-color: rgba(41, 37, 36, 0.8);
}

.nav-menu-mobile.show {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.nav-menu-mobile .nav-link,
.nav-menu-mobile .nav-link-active {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--color-text-main);
  text-align: center;
  transition: var(--transition-all);
}

.nav-menu-mobile .nav-link:hover {
  color: var(--color-primary);
  transform: translateY(-5px);
}

.nav-menu-mobile .button {
  margin-top: 1rem;
  width: auto;
  min-width: 200px;
  font-size: 1rem;
}

/*
==========================================
  Footer
==========================================
*/
.main-footer {
  background-color: var(--color-bg-footer);
  color: var(--color-text-footer);
  padding-top: 2.5rem;
  padding-bottom: 2.5rem;
  text-align: center;
}

.footer-logo {
  height: 4rem;
  /* 64px */
  width: 4rem;
  /* 64px */
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 1rem;
  border-radius: var(--border-radius-full);
  object-fit: cover;
}

.footer-title {
  font-size: 1.125rem;
  /* 18px */
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--palette-white);
}

.footer-address {
  margin-bottom: 1rem;
  color: var(--palette-white);
}

.social-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  /* 24px */
  margin-bottom: 1rem;
}

.social-link {
  color: var(--color-text-footer);
}

.social-link:hover {
  color: var(--color-text-light);
}

.social-icon {
  width: 1.5rem;
  /* 24px */
  height: 1.5rem;
  /* 24px */
}

.footer-copyright {
  font-size: 0.875rem;
  /* 14px */
  color: var(--color-text-footer-muted);
}

/*
==========================================
  Spesifikke Sider/Seksjoner
==========================================
*/

/* --- Hero (index.html) --- */
.hero-section {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-size: cover;
  background-position: center;
  text-align: center;
  color: var(--palette-white);
  padding: 2rem;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  /* top, right, bottom, left = 0 */
  background-color: rgba(0, 0, 0, 0.5);
}

.hero-content {
  position: relative;
  /* Over overlayen */
  max-width: 800px;
  /* Økt fra 600px til 800px */
  /* Sentrerer innholdet i hero selv om container er full bredde */
  margin-left: auto;
  margin-right: auto;
}

.hero-content h1,
.hero-content p {
  color: var(--palette-white);
}


/* --- Om Oss Teaser (index.html) & Om Oss (om-oss.html) --- */
.about-section .grid-container,
.om-oss-page .grid-container {
  display: grid;
  gap: 3rem;
  align-items: center;
}

.about-section .grid-image,
.om-oss-page .grid-image {
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
}

.about-section .grid-text,
.om-oss-page .grid-text {
  text-align: left;
}

.about-section .grid-text h2,
.om-oss-page .grid-text h2 {
  margin-bottom: 1.5rem;
}

/* --- Kurs Teaser (index.html) --- */
.kurs-grid {
  display: grid;
  gap: 2rem;
}

.kurs-card {
  background-color: var(--color-bg-card);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transition: transform 0.2s ease;
}

.kurs-card:hover {
  transform: translateY(-8px);
}

.kurs-card-image {
  width: 100%;
  height: 12rem;
  /* 192px */
  object-fit: cover;
}

.kurs-card-content {
  padding: 1.5rem;
}

.kurs-card-content h3 {
  color: var(--color-primary);
}

/* --- Galleri Teaser (index.html) & Galleri (galleri.html) --- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: var(--border-radius-lg);
}

.gallery-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.gallery-item:hover .gallery-image {
  transform: scale(1.1);
}

/* --- Kontakt (kontakt.html) --- */
.form-container {
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  background-color: var(--color-bg-card);
  padding: 2rem;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
}

/* --- Logg inn (login.html) --- */
.login-page-main {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  /* Mindre enn 100vh for å se header */
  padding: 4rem 0;
}

.login-form-container {
  background-color: var(--color-bg-card);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
}

.login-form-container .button {
  width: 100%;
}

/* --- Medlemsside (medlem.html) --- */
.medlem-container {
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

#new-post-container {
  background-color: var(--color-bg-card);
  padding: 1.5rem;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
  margin-bottom: 2rem;
}

#new-post-container h2 {
  color: var(--color-primary-darker);
}

#new-post-container .button {
  width: 100%;
}

.feed-item {
  background-color: var(--color-bg-card);
  padding: 1.5rem;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
  margin-bottom: 1.5rem;
}

.feed-item h3 {
  color: var(--color-primary-darker);
  margin-bottom: 0.5rem;
}

.feed-item-meta {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}

.feed-item-content {
  color: var(--color-secondary);
}

.feed-item-content p {
  color: var(--color-secondary);
}

/*
==========================================
  Responsive Design (Media Queries)
==========================================
*/

/* --- Tablet (og større) --- */
@media (min-width: 768px) {

  /* Skjul mobilmeny, vis desktop-meny */
  .mobile-menu-button {
    display: none;
  }

  .nav-menu-desktop {
    display: flex;
  }

  .nav-menu-mobile {
    display: none !important;
    /* Alltid skjult på desktop */
  }

  /* Grid-systemer */
  .about-section .grid-container,
  .om-oss-page .grid-container {
    grid-template-columns: repeat(2, 1fr);
  }

  .kurs-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .gallery-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .form-container {
    padding: 2.5rem;
  }
}

/* --- Lightbox --- */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.9);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  cursor: pointer;
}

.lightbox.active {
  display: flex;
}

.lightbox-content {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-image {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-xl);
  cursor: default;
}

.lightbox-close {
  position: absolute;
  top: -3rem;
  right: 0;
  background: none;
  border: none;
  color: white;
  font-size: 2.5rem;
  line-height: 1;
  cursor: pointer;
  transition: var(--transition-all);
}

.lightbox-close:hover {
  transform: scale(1.1);
  color: var(--color-primary);
}

@media (max-width: 768px) {
  .lightbox-close {
    top: -2.5rem;
    right: -0.5rem;
  }
}