/*
Theme Name: Midsvetrarblot Portal
Theme URI: https://midsvetrarblot.se/
Author: Mikael Linder
Description: En ordlös, mobilprioriterad portal för Miðsvetrarblót.
Version: 0.1.3
Requires at least: 6.6
Requires PHP: 8.1
Text Domain: midsvetrarblot-portal
*/

:root {
  --night-ink: #020508;
  --night-blue: #06131c;
  --night-teal: #0c2025;
  --frost: #d7e4e1;
  --frost-muted: #8da6a4;
  --ember: #ffb35a;
  --ember-deep: #a7431f;
  --gold: #d7a85e;
  --look-x: 0px;
  --look-y: 0px;
  --year-turn: 0deg;
}

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

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  overflow: clip;
  background: var(--night-ink);
}

body.portal-theme {
  color: var(--frost);
  font-family: Georgia, "Times New Roman", serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

.screen-reader-text {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.portal {
  position: relative;
  isolation: isolate;
  width: 100vw;
  height: 100svh;
  min-height: 520px;
  overflow: hidden;
  overflow: clip;
  background:
    radial-gradient(circle at 50% 64%, rgba(54, 77, 72, 0.26), transparent 34%),
    linear-gradient(180deg, #020507 0%, #06131b 43%, #0a171b 68%, #020405 100%);
  cursor: default;
  touch-action: manipulation;
}

.portal::before {
  content: "";
  position: absolute;
  z-index: 20;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 42%, transparent 0 26%, rgba(0, 0, 0, 0.18) 58%, rgba(0, 0, 0, 0.76) 118%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.28), transparent 22%, transparent 70%, rgba(0, 0, 0, 0.58));
  mix-blend-mode: multiply;
}

.portal::after {
  content: "";
  position: absolute;
  z-index: 21;
  inset: -24%;
  pointer-events: none;
  opacity: 0.24;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.95' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.44'/%3E%3C/svg%3E");
  transform: translate3d(var(--look-x), var(--look-y), 0);
  animation: grain 9s steps(8) infinite;
  mix-blend-mode: soft-light;
}

.portal[data-phase="dawn"] {
  background:
    radial-gradient(circle at 62% 37%, rgba(152, 79, 60, 0.18), transparent 30%),
    linear-gradient(180deg, #07111a 0%, #15242a 48%, #14201f 70%, #030506 100%);
}

.portal[data-phase="dusk"] {
  background:
    radial-gradient(circle at 34% 42%, rgba(91, 55, 72, 0.22), transparent 32%),
    linear-gradient(180deg, #070812 0%, #151526 44%, #0d2022 70%, #020405 100%);
}

.sky-scene {
  position: absolute;
  z-index: 1;
  inset: -3%;
  width: 106%;
  height: 106%;
  transform: translate3d(calc(var(--look-x) * -0.18), calc(var(--look-y) * -0.12), 0) scale(1.025);
  transform-origin: 50% 50%;
}

.moon-halo {
  --moon-shift: 0px;
  opacity: 0.58;
  transform-box: view-box;
  transform-origin: 1060px 188px;
  animation: moon-breathe 10s ease-in-out infinite;
}

.star {
  fill: #dfe9e6;
  opacity: 0.42;
  transform-box: fill-box;
  transform-origin: center;
  animation: star-pulse 5.5s ease-in-out infinite;
}

.star:nth-of-type(3n) {
  animation-delay: -2.2s;
  animation-duration: 7.8s;
}

.star:nth-of-type(4n) {
  animation-delay: -4.1s;
  animation-duration: 4.6s;
}

.aurora {
  opacity: 0.16;
  animation: aurora-drift 18s ease-in-out infinite alternate;
  transform-origin: center;
}

.ridge-far {
  fill: #071116;
  opacity: 0.82;
}

.ridge-near {
  fill: #03090c;
}

.forest-far {
  color: #071217;
  opacity: 0.88;
  transform: translate3d(calc(var(--look-x) * -0.34), 0, 0);
}

.forest-near {
  color: #020609;
  transform: translate3d(calc(var(--look-x) * -0.76), 0, 0);
}

.ground-frost {
  opacity: 0.72;
}

.mist {
  position: absolute;
  z-index: 4;
  left: -25%;
  width: 150%;
  height: 21vh;
  min-height: 120px;
  pointer-events: none;
  filter: blur(18px);
  background:
    radial-gradient(ellipse at 24% 60%, rgba(152, 184, 180, 0.15), transparent 25%),
    radial-gradient(ellipse at 66% 54%, rgba(154, 181, 177, 0.12), transparent 27%),
    radial-gradient(ellipse at 88% 70%, rgba(181, 199, 195, 0.11), transparent 19%);
  animation: mist-travel 22s ease-in-out infinite alternate;
}

.mist--back {
  bottom: 21%;
  opacity: 0.45;
}

.mist--front {
  z-index: 13;
  bottom: -1%;
  opacity: 0.64;
  animation-direction: alternate-reverse;
  animation-duration: 29s;
}

.hall-wrap {
  position: absolute;
  z-index: 8;
  left: 50%;
  bottom: clamp(26px, 7.5vh, 86px);
  width: min(77vw, 980px);
  aspect-ratio: 2.42 / 1;
  transform: translate3d(calc(-50% + var(--look-x) * 0.12), calc(var(--look-y) * 0.08), 0);
  filter: drop-shadow(0 44px 34px rgba(0, 0, 0, 0.82));
}

.hall-shadow {
  position: absolute;
  z-index: -2;
  left: -10%;
  right: -10%;
  bottom: -7%;
  height: 22%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.72);
  filter: blur(20px);
}

.hall-wall {
  position: absolute;
  z-index: 2;
  left: 4.5%;
  right: 4.5%;
  bottom: 0;
  height: 57%;
  overflow: hidden;
  clip-path: polygon(2% 7%, 98% 7%, 94% 100%, 6% 100%);
  background:
    repeating-linear-gradient(90deg, transparent 0 7.7%, rgba(2, 4, 4, 0.42) 7.9% 8.3%, transparent 8.6% 12%),
    linear-gradient(91deg, rgba(10, 12, 11, 0.92), rgba(32, 31, 25, 0.94) 47%, rgba(11, 13, 12, 0.96)),
    #171815;
  box-shadow: inset 0 20px 30px rgba(0, 0, 0, 0.68);
}

.hall-wall::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.42;
  background:
    repeating-linear-gradient(3deg, transparent 0 15px, rgba(184, 160, 110, 0.08) 16px 17px, transparent 18px 25px),
    radial-gradient(ellipse at 50% 0%, rgba(115, 92, 51, 0.18), transparent 46%);
}

.hall-beam {
  position: absolute;
  z-index: 4;
  top: 4%;
  bottom: 0;
  width: 1.9%;
  min-width: 8px;
  border-left: 1px solid rgba(115, 93, 56, 0.3);
  border-right: 1px solid rgba(0, 0, 0, 0.72);
  background: linear-gradient(90deg, #080a09, #25231b 43%, #0a0b09);
  box-shadow: 0 0 14px rgba(0, 0, 0, 0.64);
}

.hall-beam--1 { left: 12%; }
.hall-beam--2 { left: 29%; }
.hall-beam--3 { right: 29%; }
.hall-beam--4 { right: 12%; }

.hall-roof {
  position: absolute;
  z-index: 5;
  left: -1%;
  top: 0;
  width: 102%;
  height: 58%;
  clip-path: polygon(2% 92%, 19% 30%, 45% 3%, 55% 3%, 81% 30%, 98% 92%, 94% 100%, 6% 100%);
  background:
    repeating-linear-gradient(168deg, transparent 0 10px, rgba(174, 148, 91, 0.08) 11px 12px, transparent 13px 20px),
    repeating-linear-gradient(12deg, transparent 0 12px, rgba(0, 0, 0, 0.25) 13px 15px, transparent 16px 23px),
    linear-gradient(180deg, #171712, #0b0d0b 72%, #050706 100%);
  box-shadow: inset 0 -18px 25px rgba(0, 0, 0, 0.78);
}

.hall-roof::before {
  content: "";
  position: absolute;
  left: 4%;
  top: 5%;
  width: 92%;
  height: 34%;
  opacity: 0.4;
  filter: blur(2px);
  background: linear-gradient(174deg, transparent 36%, rgba(194, 209, 204, 0.32) 40% 46%, transparent 51%);
}

.hall-roof::after {
  content: "";
  position: absolute;
  left: 47.5%;
  top: 0;
  width: 5%;
  height: 22%;
  background: linear-gradient(90deg, #050706, #222019 48%, #050706);
  clip-path: polygon(24% 0, 76% 0, 100% 100%, 0 100%);
}

.roof-ridge {
  position: absolute;
  z-index: 7;
  top: 1.2%;
  left: 43.5%;
  width: 13%;
  height: 3.5%;
  border-radius: 100%;
  background: #050706;
  box-shadow: 0 3px 5px rgba(0, 0, 0, 0.76);
}

.roof-finial {
  position: absolute;
  z-index: 8;
  top: -5.5%;
  width: 7%;
  height: 18%;
  border: clamp(3px, .42vw, 6px) solid #070a09;
  border-top: 0;
  border-radius: 0 0 46% 46%;
  opacity: 0.94;
}

.roof-finial--left {
  left: 16%;
  transform: rotate(18deg);
}

.roof-finial--right {
  right: 16%;
  transform: rotate(-18deg);
}

.smoke-stack {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: -38%;
  width: 22%;
  height: 50%;
  transform: translateX(-50%);
  filter: blur(16px);
  opacity: 0.26;
  pointer-events: none;
}

.smoke-stack span {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 34%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(128, 145, 139, 0.26);
  animation: smoke-rise 12s ease-in infinite;
}

.smoke-stack span:nth-child(2) { animation-delay: -4s; width: 46%; }
.smoke-stack span:nth-child(3) { animation-delay: -8s; width: 58%; }

.door-glow {
  position: absolute;
  z-index: 0;
  left: 50%;
  bottom: -4%;
  width: 34%;
  aspect-ratio: 1 / 1.34;
  border-radius: 48% 48% 10% 10%;
  opacity: 0.18;
  transform: translateX(-50%) scale(0.72);
  transform-origin: 50% 80%;
  background: radial-gradient(ellipse at 50% 72%, rgba(255, 181, 83, 0.95), rgba(184, 74, 27, 0.45) 34%, transparent 72%);
  filter: blur(22px);
  transition: opacity 1.3s ease, transform 1.6s cubic-bezier(.2,.72,.16,1);
}

.door-opening {
  position: absolute;
  z-index: 5;
  left: 43%;
  bottom: 1.5%;
  width: 14%;
  height: 51%;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 74%, #ffd389 0%, #b75426 36%, #40170f 70%, #120908 100%);
  border: clamp(5px, .7vw, 11px) solid #080a08;
  border-bottom-width: clamp(3px, .35vw, 7px);
  box-shadow: 0 0 0 2px rgba(78, 62, 39, 0.62), 0 0 24px rgba(170, 72, 30, 0.16);
  perspective: 700px;
}

.door-opening::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.55;
  background:
    linear-gradient(90deg, transparent 41%, rgba(17, 8, 5, 0.72) 43% 48%, transparent 50%),
    linear-gradient(26deg, transparent 0 46%, rgba(45, 16, 8, 0.44) 47% 51%, transparent 52%);
}

.door-leaf {
  position: absolute;
  z-index: 6;
  inset: 0;
  display: grid;
  place-items: center;
  transform-origin: 0 50%;
  transform: rotateY(0deg);
  backface-visibility: hidden;
  background:
    radial-gradient(ellipse at 43% 32%, rgba(120, 83, 43, 0.18), transparent 26%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 16%, rgba(0, 0, 0, 0.34) 16.4% 17.8%, transparent 18.2% 33%),
    linear-gradient(96deg, #10120f, #2d2a20 47%, #131510);
  box-shadow: inset -18px 0 22px rgba(0, 0, 0, 0.44), inset 0 0 0 2px rgba(112, 87, 51, 0.18);
  transition: transform 1.55s cubic-bezier(.18,.78,.16,1), filter 1s ease;
}

.door-leaf::before,
.door-leaf::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 8%;
  background: linear-gradient(180deg, #070807, #25251e 48%, #080907);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}

.door-leaf::before { top: 21%; }
.door-leaf::after { bottom: 18%; }

.portal-ring {
  position: relative;
  z-index: 9;
  width: clamp(62px, 7.2vw, 104px);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #161714;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  filter: drop-shadow(0 8px 7px rgba(0, 0, 0, 0.72));
  transition: transform .3s ease, filter .4s ease;
}

.portal-ring::before {
  content: "";
  position: absolute;
  inset: 9%;
  border: clamp(7px, .8vw, 11px) solid #11130f;
  border-radius: 50%;
  box-shadow:
    inset 2px 3px 2px rgba(185, 154, 91, 0.18),
    inset -3px -4px 4px rgba(0, 0, 0, 0.72),
    0 0 0 2px rgba(0, 0, 0, 0.54);
}

.portal-ring::after {
  content: "";
  position: absolute;
  left: 42%;
  top: 0;
  width: 16%;
  height: 22%;
  border-radius: 45% 45% 20% 20%;
  background: linear-gradient(90deg, #070907, #2b2c22 48%, #070807);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.72);
}

.portal-ring:hover {
  transform: translateY(-2px) scale(1.025);
  filter: drop-shadow(0 10px 9px rgba(0, 0, 0, 0.78)) brightness(1.18);
}

.portal-ring:active {
  transform: translateY(3px) scale(0.97);
}

.portal-ring:focus-visible {
  outline: 2px solid rgba(231, 207, 157, 0.92);
  outline-offset: 7px;
}

.year-wheel {
  position: absolute;
  inset: -16%;
  width: 132%;
  height: 132%;
  opacity: 0.42;
  overflow: visible;
  pointer-events: none;
}

.year-wheel__track {
  fill: none;
  stroke: rgba(159, 171, 159, 0.42);
  stroke-width: 1.4;
  stroke-dasharray: 1 8;
}

.year-wheel__mark {
  transform-origin: 60px 60px;
  transform: rotate(var(--year-turn));
  transition: transform 1.3s cubic-bezier(.2,.8,.2,1);
}

.year-wheel__mark path {
  fill: rgba(222, 188, 118, 0.78);
}

.ember-field {
  position: absolute;
  z-index: 12;
  left: 50%;
  bottom: 12%;
  width: min(28vw, 340px);
  height: 48vh;
  transform: translateX(-50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 1s ease .5s;
}

.ember {
  position: absolute;
  bottom: 0;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #ffd28a;
  box-shadow: 0 0 8px #ff8b3d;
  animation: ember-rise 4.8s ease-out infinite;
}

.ember:nth-child(1) { left: 42%; animation-delay: -.3s; }
.ember:nth-child(2) { left: 57%; animation-delay: -1.1s; animation-duration: 5.7s; }
.ember:nth-child(3) { left: 48%; animation-delay: -2.8s; animation-duration: 4.2s; }
.ember:nth-child(4) { left: 64%; animation-delay: -3.7s; animation-duration: 6.1s; }
.ember:nth-child(5) { left: 35%; animation-delay: -4.5s; animation-duration: 5.3s; }
.ember:nth-child(6) { left: 53%; animation-delay: -5.2s; animation-duration: 6.4s; }

.wordmark {
  position: absolute;
  z-index: 18;
  left: 50%;
  top: clamp(30px, 7vh, 88px);
  width: min(86vw, 940px);
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}

.wordmark__name {
  display: block;
  color: rgba(219, 230, 225, 0.82);
  font-size: clamp(1.36rem, 3.25vw, 3.7rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: clamp(.15em, .75vw, .34em);
  text-indent: clamp(.15em, .75vw, .34em);
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.86), 0 0 30px rgba(133, 162, 157, 0.12);
  transition: color 1.4s ease, text-shadow 1.4s ease, letter-spacing 1.4s ease;
}

.wordmark__sigil {
  display: block;
  width: clamp(64px, 6vw, 92px);
  height: 1px;
  margin: clamp(15px, 2vh, 24px) auto 0;
  opacity: 0.48;
  background: linear-gradient(90deg, transparent, rgba(203, 218, 212, 0.68), transparent);
  transition: width 1.2s ease, opacity 1.2s ease, background 1.2s ease;
}

.ground-mark {
  position: absolute;
  z-index: 14;
  left: 50%;
  bottom: -20vh;
  width: min(88vw, 1040px);
  aspect-ratio: 2.25 / 1;
  transform: translateX(-50%) perspective(360px) rotateX(65deg);
  transform-origin: 50% 100%;
  border: 1px solid rgba(156, 176, 170, 0.1);
  border-radius: 50%;
  opacity: 0.42;
  pointer-events: none;
  box-shadow:
    inset 0 0 0 16px rgba(151, 174, 168, 0.012),
    inset 0 0 0 17px rgba(151, 174, 168, 0.045),
    inset 0 0 80px rgba(168, 190, 183, 0.035),
    0 0 52px rgba(0, 0, 0, 0.7);
}

.ground-mark::before,
.ground-mark::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: rgba(174, 191, 186, 0.11);
  transform: translate(-50%, -50%);
}

.ground-mark::before { width: 82%; height: 1px; }
.ground-mark::after { width: 1px; height: 82%; }

.portal.is-open .door-leaf {
  transform: rotateY(-63deg);
  filter: brightness(0.84);
}

.portal.is-open .door-glow {
  opacity: 0.94;
  transform: translateX(-50%) scale(1.32);
}

.portal.is-open .ember-field {
  opacity: 1;
}

.portal.is-open .wordmark__name {
  color: rgba(246, 225, 184, 0.96);
  letter-spacing: clamp(.12em, .66vw, .29em);
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.92), 0 0 32px rgba(224, 151, 70, 0.28);
}

.portal.is-open .wordmark__sigil {
  width: clamp(110px, 11vw, 168px);
  opacity: 0.9;
  background: linear-gradient(90deg, transparent, rgba(234, 177, 94, 0.86), transparent);
}

.portal.is-open .portal-ring {
  transform: translateX(-7%) rotate(-18deg);
}

@keyframes star-pulse {
  0%, 100% { opacity: 0.22; transform: scale(.8); }
  52% { opacity: 0.78; transform: scale(1.25); }
}

@keyframes moon-breathe {
  0%, 100% { opacity: 0.44; transform: translateX(var(--moon-shift)) scale(.98); }
  50% { opacity: 0.68; transform: translateX(var(--moon-shift)) scale(1.03); }
}

@keyframes aurora-drift {
  0% { transform: translateX(-2%) skewX(-3deg); opacity: .08; }
  100% { transform: translateX(3%) skewX(2deg); opacity: .22; }
}

@keyframes mist-travel {
  0% { transform: translate3d(-3%, 1%, 0) scale(1); }
  100% { transform: translate3d(4%, -2%, 0) scale(1.05); }
}

@keyframes smoke-rise {
  0% { transform: translate3d(-40%, 16%, 0) scale(.6); opacity: 0; }
  25% { opacity: .52; }
  100% { transform: translate3d(45%, -260%, 0) scale(1.7); opacity: 0; }
}

@keyframes ember-rise {
  0% { transform: translate3d(0, 10px, 0) scale(.55); opacity: 0; }
  16% { opacity: .95; }
  72% { opacity: .58; }
  100% { transform: translate3d(26px, -42vh, 0) scale(.15); opacity: 0; }
}

@keyframes grain {
  0% { transform: translate3d(-3%, 2%, 0); }
  25% { transform: translate3d(2%, -4%, 0); }
  50% { transform: translate3d(4%, 3%, 0); }
  75% { transform: translate3d(-4%, -2%, 0); }
  100% { transform: translate3d(1%, 4%, 0); }
}

@media (max-width: 760px) {
  .portal {
    min-height: 460px;
  }

  .wordmark {
    top: max(30px, env(safe-area-inset-top));
  }

  .wordmark__name {
    font-size: clamp(1.25rem, 7vw, 2rem);
    letter-spacing: .16em;
    text-indent: .16em;
  }

  .hall-wrap {
    bottom: max(44px, 7vh);
    width: 128vw;
    min-width: 560px;
  }

  .portal-ring {
    width: clamp(58px, 15vw, 68px);
  }

  .moon-halo {
    --moon-shift: -140px;
  }

  .mist--back { bottom: 19%; }
  .mist--front { bottom: 1%; }

  .ground-mark {
    bottom: -10vh;
    width: 132vw;
  }
}

@media (max-height: 620px) and (orientation: landscape) {
  .portal { min-height: 400px; }
  .wordmark { top: 24px; }
  .wordmark__name { font-size: clamp(1.1rem, 4vw, 1.9rem); }
  .wordmark__sigil { margin-top: 12px; }
  .hall-wrap { bottom: 22px; width: min(66vw, 680px); }
  .portal-ring { width: 62px; }
}

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

  .sky-scene,
  .forest-far,
  .forest-near,
  .hall-wrap,
  .portal::after {
    transform: none !important;
  }

  .hall-wrap {
    left: 50%;
    transform: translateX(-50%) !important;
  }
}
