/* ================== Base & layout ================== */
@font-face{
  font-family: 'ArchitectsDaughter';
  src: url('fonts/ArchitectsDaughter.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

*,
*::before,
*::after{
  box-sizing: border-box;
}

html,
body{
  height: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

/* Tema-variabler */
:root{
  --glass-alpha: 0.2;
  --glass-blur: 5px;
  --text-color: #f9fafb;
  --edge-shadow: rgba(0,0,0,0.35);
}

/* Body: sticky footer + baggrundslag */
body{
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  color: var(--text-color);

  background-color: #0b0b0b;
  position: relative;
  isolation: isolate;
}

/* Baggrundsbilledet ligger i sit eget lag, så det kan roteres på mobil */
body::before{
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;

  background-image:
    linear-gradient(135deg, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0.35) 100%),
    url('images/bg.jpg');

  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat;

  transform: none;
  transform-origin: center center;
  backface-visibility: hidden;
}

/* Når mobilen holdes lodret: roter baggrunden */
@media (max-width: 768px) and (orientation: portrait){
  body::before{
    inset: auto;
    top: 50%;
    left: 50%;

    width: 100vh;
    width: 100dvh;
    height: 100vw;
    height: 100dvw;

    transform: translate(-50%, -50%) rotate(90deg);
    background-size: cover, cover;
    background-position: center, center;
    will-change: transform;
  }
}

/* Når mobilen vendes vandret: normal baggrund igen */
@media (max-width: 768px) and (orientation: landscape){
  body::before{
    inset: 0;
    top: auto;
    left: auto;

    width: auto;
    height: auto;

    transform: none;
    will-change: auto;
  }
}

/* ================== Links ================== */
a{
  color: #93c5fd;
  font-family: ArchitectsDaughter, Arial, sans-serif;
  font-size: 1.1rem;
  font-weight: 500;
  text-decoration: none;
  transition: color .2s ease, opacity .2s ease, text-decoration-color .2s ease;
}

a:hover{
  color: #bfdbfe;
  text-decoration: underline;
}

a:active{
  opacity: 0.7;
}

@media (max-width: 768px){
  a{
    font-size: 1.2rem;
    padding: 8px 0;
    display: inline-block;
  }
}

/* ================== Link-klasser til custom HTML ================== */
.content-view a.link{
  color: #93c5fd;
  font-family: ArchitectsDaughter, Arial, sans-serif;
  font-size: 1.1rem;
  font-weight: 500;
  text-decoration: none;
}

.content-view a.link:hover{
  color: #bfdbfe;
  text-decoration: underline;
}

.content-view a.link--button{
  display: inline-block;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.12);
  color: #ffffff;
  text-decoration: none;
}

.content-view a.link--button:hover{
  background: rgba(255,255,255,0.16);
  border-color: rgba(255,255,255,0.28);
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
  text-decoration: none;
}

.content-view a.link--plain{
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
  text-decoration: underline;
}

.content-view a.link--muted{
  color: rgba(255,255,255,.75);
}

.content-view a.link--muted:hover{
  color: #ffffff;
}

/* ================== Header / Footer: sort glas + blød kant ================== */
.site-header,
.site-footer{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(0,0,0,var(--glass-alpha));
  border: none;
  border-radius: 0;
  backdrop-filter: blur(var(--glass-blur)) saturate(120%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(120%);
}

.site-header{
  box-shadow: 0 12px 24px var(--edge-shadow);
}

.site-footer{
  gap: 12px;
  flex-wrap: wrap;
  position: relative;
  box-shadow: 0 -12px 24px var(--edge-shadow);
}

.logo img{
  height: 48px;
  width: auto;
  display: block;
}

.title h1{
  font-family: 'ArchitectsDaughter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  font-weight: 400;
  letter-spacing: .2px;
  margin: 0;
  font-size: 1.8rem;
}

/* ================== Content fylder resten ================== */
.content-wrap{
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  min-height: 0;
}

.content-fill{
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

/* ====== Visningstilstand: tekst direkte på baggrunden ====== */
.content-view{
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 20px;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* ====== Editor-tilstand: hvid papirflade ====== */
#editorForm{
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;

  background: #ffffff;
  color: #111827;
  padding: 24px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.35);

  width: min(1400px, 96vw);
  margin: 24px auto;
  min-height: 78vh;
}

.editor{
  flex: 1 1 auto;
  min-height: 60vh;
  width: 100%;

  background: #ffffff;
  color: #111827;
  caret-color: #111827;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px;

  font: 15px/1.6 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  outline: none;
  resize: vertical;
  overflow: auto;
}

#editorForm ::placeholder{
  color: #6b7280;
}

/* ================== Knapper ================== */
.footer-actions{
  display: flex;
  gap: 10px;
  align-items: center;
}

.inline{
  display: inline;
}

.btn{
  appearance: none;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.12);
  color: #ffffff;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .02s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease;
}

.btn:hover{
  background: rgba(255,255,255,0.16);
  border-color: rgba(255,255,255,0.28);
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
}

.btn:active{
  transform: translateY(1px);
}

.btn.primary{
  background: #111827;
  border-color: #111827;
}

/* ================== Typografi for indhold ================== */
.content-view{
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.content-view h1,
.content-view h2,
.content-view h3,
.content-view h4,
.content-view h5,
.content-view h6{
  margin: 1.6rem 0 0.8rem;
  line-height: 1.25;
  font-weight: 800;
  color: #ffffff;
}

.content-view h1{ font-size: 2.25rem; }
.content-view h2{ font-size: 1.875rem; }
.content-view h3{ font-size: 1.5rem; }
.content-view h4{ font-size: 1.25rem; }
.content-view h5{ font-size: 1.125rem; }
.content-view h6{
  font-size: 1rem;
  letter-spacing: .02em;
}

.content-view p{
  margin: 0 0 1rem;
}

.content-view p + p{
  margin-top: 0.5rem;
}

.content-view strong,
.content-view b{
  font-weight: 700;
}

.content-view em,
.content-view i{
  font-style: italic;
}

.content-view a{
  color: #93c5fd;
  text-decoration: none;
}

.content-view a:hover{
  text-decoration: underline;
}

.content-view ul,
.content-view ol{
  margin: 0.75rem 0 1rem 1.5rem;
  padding: 0;
}

.content-view li + li{
  margin-top: .35rem;
}

.content-view ul{
  list-style: disc;
}

.content-view ol{
  list-style: decimal;
}

.content-view figure{
  margin: 1.25rem 0;
}

.content-view figcaption{
  font-size: .9rem;
  color: rgba(255,255,255,.8);
}

.content-view blockquote{
  margin: 1.25rem 0;
  padding: .75rem 1rem;
  border-left: 4px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.05);
  color: #e5e7eb;
  border-radius: 6px;
}

.content-view code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: .95em;
  background: rgba(0,0,0,.45);
  padding: .15em .4em;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.12);
}

.content-view pre{
  margin: 1rem 0;
  padding: 1rem;
  overflow: auto;
  background: rgba(0,0,0,.55);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.12);
}

.content-view pre code{
  background: transparent;
  border: 0;
  padding: 0;
  font-size: 0.95rem;
  line-height: 1.6;
  display: block;
}

.content-view hr{
  height: 1px;
  border: 0;
  margin: 2rem 0;
  background: rgba(255,255,255,.18);
}

.content-view table{
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.95rem;
}

.content-view th,
.content-view td{
  padding: .75rem .8rem;
  border-bottom: 1px solid rgba(255,255,255,.12);
  text-align: left;
  vertical-align: top;
}

.content-view thead th{
  background: rgba(255,255,255,.06);
  font-weight: 700;
}

.content-view tbody tr:nth-child(odd){
  background: rgba(255,255,255,.02);
}

.content-view ::selection{
  background: rgba(147,197,253,.35);
}

/* ================== Billeder – pæn default uden upscaling ================== */
img,
video{
  max-width: 100%;
  height: auto;
}

.content-view img:not([class]){
  display: block;
  margin: 0.75rem auto;
  width: auto;
  max-width: min(100%, 960px);
  height: auto;

  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  background: #0b0b0b;
}

/* ====== .img utility med størrelses-modifiers ====== */
.content-view figure.img{
  margin: 1.25rem auto;
  max-width: min(90vw, var(--img-max, 960px));
  text-align: center;
}

.content-view img.img,
.content-view figure.img > img{
  display: block;
  margin: 0.75rem auto;
  width: auto;
  max-width: min(100%, var(--img-max, 960px));
  height: auto;

  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  background: #0b0b0b;
  transition: transform .12s ease, box-shadow .2s ease;
}

.content-view img.img:hover,
.content-view figure.img > img:hover{
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.42);
}

.content-view figure.img > figcaption{
  margin-top: .5rem;
  font-size: .92rem;
  color: rgba(255,255,255,.8);
}

/* Størrelses-modifiers */
.content-view .img.img--sm{ --img-max: 480px; }
.content-view .img.img--md{ --img-max: 720px; }
.content-view .img.img--lg{ --img-max: 960px; }
.content-view .img.img--xl{ --img-max: 1200px; }
.content-view .img.img--full{ --img-max: 100vw; }
.content-view .img.img--native{ --img-max: 99999px; }

/* ===== Billede-justering: venstre/højre wrap ===== */
.content-view img.img.img--right,
.content-view figure.img.img--right{
  float: right;
  margin: .5rem 0 .75rem 1rem;
  max-width: min(48%, var(--img-max, 480px));
}

.content-view img.img.img--left,
.content-view figure.img.img--left{
  float: left;
  margin: .5rem 1rem .75rem 0;
  max-width: min(48%, var(--img-max, 480px));
}

/* På mobil/tablet: drop floats, vis centralt under tekst */
@media (max-width: 768px){
  .content-view img.img.img--left,
  .content-view img.img.img--right,
  .content-view figure.img.img--left,
  .content-view figure.img.img--right{
    float: none;
    display: block;
    margin: .75rem auto;
    max-width: min(100%, var(--img-max, 960px));
  }
}

/* ================== Tekstjustering ================== */
.content-view .text-left{
  text-align: left;
}

.content-view .text-center{
  text-align: center;
}

.content-view .text-right{
  text-align: right;
}

.content-view .text-justify{
  text-align: justify;
  text-justify: inter-word;
}

/* Layout-width wrappers */
.content-view .narrow{
  max-width: 60ch;
  margin: 0 auto;
}

.content-view .wide{
  max-width: 80ch;
  margin: 0 auto;
}

/* Desktop-only alignment */
@media (min-width: 769px){
  .content-view .md-text-right{
    text-align: right;
  }

  .content-view .md-text-left{
    text-align: left;
  }

  .content-view .md-text-center{
    text-align: center;
  }
}

/* ================== A11Y utils ================== */
.sr-only{
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

:focus-visible{
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
}

/* Formularfelter i footer på mørk baggrund */
.site-footer input[type="password"]{
  padding: 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.24);
  background: rgba(255,255,255,0.12);
  color: #fff;
}

.site-footer input[type="password"]::placeholder{
  color: #cbd5e1;
}

/* ================== Flash/Status som toast over footeren ================== */
.flash{
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translate(-50%, -10px);
  z-index: 1000;

  display: inline-flex;
  align-items: center;
  gap: 8px;

  max-width: min(720px, 90vw);
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.35);

  font-size: 14px;
  line-height: 1.4;
  color: #eafaf2;

  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 10px 24px rgba(0,0,0,.35);

  transition: opacity .35s ease, transform .25s ease;
  cursor: pointer;
}

.flash--ok{
  background: rgba(16,185,129,0.20);
  border-color: rgba(16,185,129,0.55);
  color: #d1fae5;
}

.flash--error{
  background: rgba(239,68,68,0.22);
  border-color: rgba(239,68,68,0.55);
  color: #fecaca;
}

.flash.is-hidden{
  opacity: 0;
  transform: translate(-50%, -14px) scale(0.98);
  pointer-events: none;
}

/* ================== Mobile ≤640px ================== */
@media (max-width: 640px){
  body{
    padding-bottom: env(safe-area-inset-bottom);
  }

  .site-header{
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    padding: 12px 14px;
    box-shadow: 0 8px 16px var(--edge-shadow);
  }

  .logo img{
    height: 40px;
  }

  .title h1{
    font-size: 1.25rem;
  }

  .site-footer{
    display: none !important;
  }

  .flash{
    display: none;
  }

  #editorForm{
    width: 100%;
    margin: 12px;
    padding: 16px;
    min-height: 70vh;
  }

  .editor{
    min-height: 55vh;
  }

  .content-view h1{ font-size: 1.9rem; }
  .content-view h2{ font-size: 1.6rem; }
  .content-view h3{ font-size: 1.3rem; }

  /* Centrer tekst som default på mobil */
  .content-view,
  .content-view p,
  .content-view h1,
  .content-view h2,
  .content-view h3,
  .content-view h4,
  .content-view h5,
  .content-view h6,
  .content-view blockquote,
  .content-view figcaption,
  .content-view li{
    text-align: center;
  }

  /* Respekter eksplicit venstrejustering */
  .content-view .text-left,
  .content-view .text-left p,
  .content-view .text-left h1,
  .content-view .text-left h2,
  .content-view .text-left h3,
  .content-view .text-left h4,
  .content-view .text-left h5,
  .content-view .text-left h6,
  .content-view .text-left blockquote,
  .content-view .text-left figcaption,
  .content-view .text-left li{
    text-align: left !important;
  }

  /* Respekter eksplicit centrering */
  .content-view .text-center,
  .content-view .text-center p,
  .content-view .text-center h1,
  .content-view .text-center h2,
  .content-view .text-center h3,
  .content-view .text-center h4,
  .content-view .text-center h5,
  .content-view .text-center h6,
  .content-view .text-center blockquote,
  .content-view .text-center figcaption,
  .content-view .text-center li{
    text-align: center !important;
  }

  /* Respekter eksplicit højrejustering */
  .content-view .text-right,
  .content-view .text-right p,
  .content-view .text-right h1,
  .content-view .text-right h2,
  .content-view .text-right h3,
  .content-view .text-right h4,
  .content-view .text-right h5,
  .content-view .text-right h6,
  .content-view .text-right blockquote,
  .content-view .text-right figcaption,
  .content-view .text-right li{
    text-align: right !important;
  }

  /* Respekter eksplicit justified tekst */
  .content-view .text-justify,
  .content-view .text-justify p,
  .content-view .text-justify h1,
  .content-view .text-justify h2,
  .content-view .text-justify h3,
  .content-view .text-justify h4,
  .content-view .text-justify h5,
  .content-view .text-justify h6,
  .content-view .text-justify blockquote,
  .content-view .text-justify figcaption,
  .content-view .text-justify li{
    text-align: justify !important;
    text-justify: inter-word;
  }

  /* Lister ser pænest ud med bullets/tal indenfor ved centreret tekst */
  .content-view ul,
  .content-view ol{
    list-style-position: inside;
    margin-left: 0;
  }

  /* Men ved eksplicit venstre/højre/justify bruges normal listeplacering */
  .content-view ul.text-left,
  .content-view ol.text-left,
  .content-view .text-left ul,
  .content-view .text-left ol,
  .content-view ul.text-right,
  .content-view ol.text-right,
  .content-view .text-right ul,
  .content-view .text-right ol,
  .content-view ul.text-justify,
  .content-view ol.text-justify,
  .content-view .text-justify ul,
  .content-view .text-justify ol{
    list-style-position: outside;
    margin-left: 1.5rem;
  }

  /* Undtagelser – behold venstrejusteret for læsbarhed */
  .content-view pre,
  .content-view code,
  .content-view table,
  .content-view thead th,
  .content-view tbody td,
  .content-view tfoot td{
    text-align: left !important;
  }
}

/* ================== Tablet ≤768px ================== */
@media (max-width: 768px){
  .title h1{
    font-size: 1.35rem;
  }
}

/* ================== Browser fallback ================== */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))){
  .site-header,
  .site-footer{
    background: rgba(0,0,0,0.55);
  }

  .flash{
    background: rgba(0,0,0,0.7);
  }
}

/* ================== Touch-optimering ================== */
@media (hover: none) and (pointer: coarse){
  .btn{
    min-height: 44px;
  }

  a{
    text-underline-offset: 3px;
  }

  .content-view img.img:hover,
  .content-view figure.img > img:hover{
    transform: none;
  }
}

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

  a,
  .btn,
  .flash,
  .content-view img.img,
  .content-view figure.img > img{
    transition: none !important;
  }

  .content-view img.img:hover,
  .content-view figure.img > img:hover{
    transform: none;
  }
}
