/* Grundregler och gemensam typografi */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-main);
  color: var(--color-dark-petrol-green);
  background: var(--page-bg);
  font-size: var(--font-size-body-sm);
  font-weight: 400;
  line-height: var(--line-height);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}

h1, h2, h3, p {
  margin-top: 0;
}

h1, h2, h3 {
  font-weight: 700;
  overflow-wrap: anywhere;
}

h1 { font-size: var(--font-size-headline-1); }
h2 { font-size: var(--font-size-headline-2); }
h3 { font-size: var(--font-size-headline-3); }
.intro { font-size: var(--font-size-body-md); }
small, .form-note, .account-box .back {
  font-size: var(--font-size-body-xs);
}

.small-title, .hero-label {
  font-weight: 400;
  text-transform: uppercase;
}

.benefit h2, .policy-toc h2, body .cookie-banner h2 {
  font-size: var(--font-size-headline-3);
}

.close-contact, .close-cookie, .close-download, .step-number {
  font-size: var(--font-size-headline-2);
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Formulär */
button, input, textarea {
  font: inherit;
}

input:not([type="checkbox"], [type="radio"]), textarea {
  min-width: 0;
  min-height: var(--control-height);
  padding: var(--space-xs) var(--space-m);
  border: 1px solid #b6c7c7;
  border-radius: var(--radius-round);
  background: white;
  font-weight: 400;
  color: var(--color-dark-petrol-green);
}

textarea {
  min-height: 96px;
  padding: var(--space-s);
  border-radius: var(--radius);
}

button, .button {
  font-size: var(--button-font-size);
}

button {
  min-width: var(--control-height);
  min-height: var(--control-height);
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid var(--color-orange);
  outline-offset: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: calc(-1 * var(--space-xs));
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin: auto;
  background: white;
  border-radius: var(--radius-round);
  img {
    width: 32px;
    height: 32px;
  }
}

/* Knappar */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  min-height: var(--control-height);
  text-decoration: none;
  padding: var(--space-xs) var(--button-padding-inline);
  border: 2px solid transparent;
  border-radius: var(--radius-round);
  cursor: pointer;
  font-weight: 700;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

.button-orange {
  background: var(--color-orange);
  color: white;
}

.button-outline {
  border-color: var(--color-orange);
  color: var(--color-orange);
  background: transparent;
}

/* Meny */
.header {
  display: flex;
  align-items: center;
  position: relative;
  z-index: 20;
  background: var(--page-bg);
  .logo {
    flex-shrink: 0;
    text-decoration: none;
  }

  nav {
    display: flex;
    align-items: center;
    width: auto;
    order: initial;
    margin: 0 auto;
    gap: var(--space-m);
    a {
      padding: var(--space-xs) 0;
      text-decoration: none;
      font-weight: 700;
      white-space: nowrap;
      position: relative;
    }

    .current {
      color: var(--color-dark-petrol-green);
      &::after {
        content: "";
        position: absolute;
        height: 2px;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--color-orange);
        border-radius: var(--radius);
      }
    }
  }

  .header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    flex-shrink: 0;
    gap: var(--space-xs);

    .button {
      padding-inline: var(--header-button-padding-inline);
      white-space: nowrap;
    }
  }

  .menu-button {
    display: none;
    margin-left: auto;
    width: var(--control-height);
    height: var(--control-height);
    padding: var(--space-xs);
    border: 1px solid #dce5e5;
    border-radius: var(--radius);
    background: transparent;
    color: inherit;
  }

  height: 80px;
  padding: 0 var(--gutter);
  gap: var(--space-l);
  flex-wrap: nowrap;
  .logo img {
    width: 140px;
  }

  @media (max-width: 850px) {
    height: auto;
    min-height: 80px;
    padding-block: var(--space-s);
    flex-wrap: wrap;
    gap: var(--space-s);
    .menu-button {
      display: grid;
      place-items: center;
    }

    nav, .header-actions {
      display: none;
      width: 100%;
      order: 3;
    }

    nav {
      flex-direction: column;
      align-items: stretch;
      gap: var(--space-xs);
      padding-block: var(--space-s);
    }

    .header-actions {
      order: 4;
    }

    &.menu-open {
      nav, .header-actions {
        display: flex;
      }
    }
  }
}

/* Footer */
.footer {
  background-color: var(--color-dark-petrol-green);
  color: white;
  .footer-links {
    display: flex;
    flex-direction: column;
    gap: var(--space-s);
    a {
      color: white;
      text-decoration: none;
    }
  }

  .newsletter {
    margin: 0;
    div {
      display: flex;
      overflow: hidden;
      border-radius: var(--radius-round);
      background: white;
      box-shadow: inset 0 0 0 1px #b6c7c7;

      &:focus-within {
        outline: 3px solid var(--color-orange);
        outline-offset: 4px;
      }
    }

    input {
      min-width: 0;
      width: 100%;
      border: 0;
      border-radius: 0;
      background: transparent;
      color: var(--color-dark-petrol-green);
      &::placeholder {
        color: var(--color-dark-petrol-green);
      }
    }

    button {
      width: var(--control-height);
      border: 0;
      border-radius: 0;
      background: transparent;
      color: var(--color-dark-petrol-green);
      flex-shrink: 0;
      transition: color 180ms ease;

      &:is(:hover, :focus-visible) {
        color: var(--color-button-hover);
      }

      &:active {
        color: var(--color-button-pressed);
        transition-duration: 0s;
      }
    }

    p {
      margin: var(--space-xs) 0 var(--space-s);
    }
  }

  margin-top: 0;
  padding: var(--space-xl) max(var(--space-m), calc((100% - var(--content-width)) / 2));
  display: grid;
  grid-template-columns: 1.15fr .7fr .7fr 1fr 1.2fr;
  gap: var(--space-l);
  position: relative;
  overflow: hidden;
  isolation: isolate;
  &::before, &::after {
    content: "";
    position: absolute;
    z-index: -1;
    pointer-events: none;
    width: 390px;
    height: 640px;
    top: calc(50% - 320px);
    background: url('../images/pattern.svg') center / contain no-repeat;
  }

  &::before {
    left: -140px;
    transform: rotate(180deg);
  }

  &::after {
    right: -50px;
  }

  .footer-logo {
    img {
      width: 132px;
    }

    p {
      margin-top: var(--space-s);
    }
  }

  @media (max-width: 850px) {
    grid-template-columns: repeat(3, 1fr);
    .footer-logo {
      grid-column: 1 / -1;
    }

    .newsletter {
      grid-column: 1 / -1;
      max-width: 320px;
    }
  }

  @media (max-width: 600px) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-m);
    padding-block: var(--space-l);

    .footer-links {
      min-width: 0;
      gap: var(--space-xs);
      overflow-wrap: anywhere;
    }

    .footer-logo { grid-column: 1 / -1; }
    .newsletter {
      grid-column: 1 / -1;
      max-width: none;
      min-width: 0;
      align-self: start;
      button { width: var(--control-height); }
    }

    &::before, &::after {
      display: block;
      width: 320px;
      height: 520px;
      background-position: center;
      background-size: contain;
      mask-image: radial-gradient(ellipse, black 45%, transparent 72%);
    }

    &::before {
      top: -112px;
      bottom: auto;
      left: -144px;
      right: auto;
      transform: rotate(180deg);
      opacity: .5;
    }

    &::after {
      top: auto;
      bottom: -112px;
      left: auto;
      right: -144px;
      transform: none;
      opacity: .65;
    }
  }

  .cookie-settings-link {
    border: 0;
    padding: 0;
    background: transparent;
    color: white;
    text-align: left;
    text-decoration: none;
  }

  a:hover, .cookie-settings-link:hover {
    text-decoration: underline;
    text-underline-offset: 4px;
  }
}

/* Kontaktformuläret */
#kontakt {
  opacity: 0;
  transform: translateY(16px) scale(.98);
  transition: opacity 220ms ease, transform 220ms ease, display 220ms allow-discrete, overlay 220ms allow-discrete;
  &:popover-open {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  &::backdrop {
    background: rgb(0 0 0 / 0%);
    transition: background 220ms ease, display 220ms allow-discrete, overlay 220ms allow-discrete;
  }

  &:popover-open::backdrop {
    background: rgb(0 0 0 / 50%);
  }
}

@starting-style {
  #kontakt:popover-open {
    opacity: 0;
    transform: translateY(16px) scale(.98);
  }

  #kontakt:popover-open::backdrop {
    background: rgb(0 0 0 / 0%);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }

  .download-link::after, .cookie-banner {
    animation: none;
  }
}

.scroll-top {
  --scroll-progress: 0;
  position: fixed;
  z-index: 50;
  right: max(var(--space-m), env(safe-area-inset-right));
  bottom: max(var(--space-l), env(safe-area-inset-bottom));
  width: 50px;
  height: 50px;
  padding: 3px;
  border: 0;
  border-radius: var(--radius-round);
  background: conic-gradient(var(--color-orange) calc(var(--scroll-progress) * 1turn), #dce8e8 0);
  color: var(--color-dark-petrol-green);
  box-shadow: 0 6px 20px rgb(0 57 61 / 18%);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms;
  span {
    display: grid;
    place-items: center;
    height: 100%;
    border-radius: inherit;
    background: white;
    &::before {
      content: "";
      width: 22px;
      height: 22px;
      background: currentColor;
      mask: url("../images/arrow-up.svg") center / contain no-repeat;
    }
  }

  &.visible {
    opacity: 1;
    visibility: visible;
    transform: none;
  }

  @media (max-width: 700px) {
    width: var(--control-height);
    height: var(--control-height);
    right: max(var(--space-s), env(safe-area-inset-right));
    bottom: max(var(--space-s), env(safe-area-inset-bottom));
  }
}

.download-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-s);
  &::after {
    content: "↓";
    display: inline-block;
  }
}

.header-actions .current {
  box-shadow: 0 0 0 3px rgb(255 104 10 / 18%);
}

/* Cookies */
body .cookie-banner {
  position: fixed;
  z-index: 100;
  inset: auto var(--space-m) var(--space-m);
  max-width: 840px;
  margin-inline: auto;
  padding: var(--space-m);
  border: 1px solid #d2dfdf;
  border-radius: var(--radius);
  background: white;
  color: var(--color-dark-petrol-green);
  box-shadow: 0 10px 45px rgb(0 0 0 / 18%);
  animation: cookieIn 240ms ease-out;
  h2 {
    margin: 0 0 var(--space-xs);
  }

  p {
    margin: 0;
  }

  a {
    text-decoration: underline;
    text-underline-offset: 3px;
  }

  .cookie-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-top: var(--space-s);
  }

  .cookie-settings-link {
    border: 0;
    padding: var(--space-xs);
    background: transparent;
    color: inherit;
    text-decoration: none;
    &:hover { text-decoration: underline; }
  }

  @media (max-width: 700px) {
    inset: auto var(--space-s) var(--space-s);
    padding: var(--space-s);
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    .cookie-actions {
      display: grid;
      grid-template-columns: 1fr;
      [data-open-settings] {
        grid-column: 1 / -1;
      }
    }
  }
}

body .cookie-settings {
  width: min(560px, calc(100% - 24px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: var(--space-l);
  border: 0;
  border-radius: var(--radius);
  color: var(--color-dark-petrol-green);
  background: white;
  &::backdrop {
    background: rgb(0 0 0 / 55%);
  }

  h2 {
    padding-right: var(--space-xl);
    margin: 0 0 var(--space-s);
  }

  p {
    margin: 0 0 var(--space-m);
  }

  fieldset {
    border: 0;
    padding: 0;
    margin: 0;
  }

  .cookie-row {
    padding: var(--space-s) 0;
    border-top: 1px solid #dce8e8;
    label {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: var(--space-m);
      font-weight: 700;
    }

    input {
      width: 22px;
      height: 22px;
      accent-color: var(--color-dark-petrol-green);
      flex-shrink: 0;
    }

    p {
      margin: var(--space-xs) 0 0;
    }
  }

  .cookie-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-s);
    margin-top: var(--space-m);
  }

  .close-cookie {
    position: absolute;
    top: var(--space-s);
    right: var(--space-s);
    width: var(--control-height);
    height: var(--control-height);
    padding: 0;
    border: 0;
    border-radius: var(--radius-round);
    background: transparent;
    color: inherit;
  }
}

body:has(.cookie-banner:not([hidden])) .scroll-top {
  visibility: hidden;
}

@keyframes cookieIn {
  from {
    opacity: 0;
    transform: translateY(15px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* Appsektion */
.app-section {
  max-width: var(--content-width);
  margin: var(--section-gap) auto;
  .app-box {
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--color-dark-petrol-green);
  }

  .app-image {
    width: 100%;
    height: 100%;
    min-height: 420px;
    object-fit: cover;
  }

  .app-text {
    padding: var(--space-l);
    color: white;
    background: url('../images/pattern.svg') no-repeat right -65px bottom -130px / 290px auto;
    .small-title {
      text-transform: uppercase;
      margin-bottom: var(--space-xs);
    }

    h2 {
      margin-bottom: var(--space-m);
    }

    .app-description {
      margin-bottom: var(--space-m);
    }

    ul {
      list-style: none;
      padding: 0;
      margin: 0 0 var(--space-l);
      display: grid;
      gap: var(--space-s);
    }

    li {
      padding-left: var(--space-m);
      position: relative;

      &::before {
        content: "";
        position: absolute;
        width: 15px;
        height: 15px;
        left: 0;
        top: 3px;
        background: url('../images/icons/check.svg') center / contain no-repeat;
        filter: brightness(0) invert(1);
      }
    }
  }

  @media (max-width: 1168px) {
    margin-inline: var(--space-m);
  }

  @media (max-width: 700px) {
    .app-box {
      grid-template-columns: 1fr;
    }

    .app-image {
      min-height: 0;
      height: 280px;
    }

    .app-text {
      padding: var(--space-l) var(--space-m);
    }
  }
}

/* Informationssektioner med bild och text bredvid varandra */
.info-section {
  padding: var(--section-gap) var(--gutter);
  background: var(--page-bg);
  scroll-margin-top: var(--space-m);
}

.info-content {
  max-width: var(--content-width);
  margin-inline: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
  align-items: center;
}

.info-text .small-title {
  margin: 0 0 var(--space-xs);
  text-transform: uppercase;
}

.info-section .info-text h2 {
  margin: 0 0 var(--space-m);
}

.info-text p:not(.small-title) {
  margin: 0 0 var(--space-s);
}

.info-text .button {
  margin-top: var(--space-xs);
}

.info-image {
  width: 100%;
  height: 360px;
  object-fit: cover;
  border-radius: var(--radius);
}

@media (max-width: 700px) {
  .info-content {
    grid-template-columns: 1fr;
  }

  .info-image {
    height: 260px;
  }
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: var(--space-xs);
  left: var(--space-xs);
  padding: var(--space-s);
  background: white;
  color: var(--color-dark-petrol-green);
  transform: translateY(-150%);
  text-decoration: none;
}

.skip-link:focus {
  transform: none;
}

.newsletter input:focus {
  outline: none;
}

.newsletter input:user-invalid:not(:placeholder-shown) {
  box-shadow: inset 0 0 0 2px #d83b3b;
}

@media (max-width: 850px) {
  .header nav, .header .header-actions {
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 140ms ease, transform 140ms ease, display 140ms allow-discrete;
  }

  .header.menu-open nav, .header.menu-open .header-actions {
    opacity: 1;
    transform: translateY(0);
  }

  @starting-style {
    .header.menu-open nav, .header.menu-open .header-actions {
      opacity: 0;
      transform: translateY(-6px);
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .header nav, .header .header-actions { transition: none; }
}

/* Hero höjd, text och bild */
.hero {
  background: var(--color-dark-petrol-green);
  color: white;
  .hero-content {
    display: grid;
    grid-template-columns: 1fr 1.15fr;
    min-height: var(--hero-height);
  }
  .hero-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: var(--hero-content-gap);
    min-width: 0;
    min-height: var(--hero-height);
    padding: var(--hero-padding-block) var(--space-l) var(--hero-padding-block) var(--gutter);
    h1 {
      max-width: 100%;
      margin: 0;
      font-size: var(--font-size-title);
      text-wrap: balance;
      line-height: var(--hero-title-line-height);
    }
    > p:not(.hero-label) {
      max-width: var(--hero-text-width);
      margin: 0;
      font-size: var(--hero-description-size);
    }
    > .button, > .hero-actions { margin-top: var(--space-xs); }
  }
  .hero-image {
    position: relative;
    min-width: 0;
    overflow: hidden;
    border-top-left-radius: var(--radius);
    clip-path: var(--diagonal-flippad, polygon(18% 0, 100% 0, 100% 100%, 0 100%));
  }
  .hero-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}

input::placeholder, textarea::placeholder {
  color: inherit;
  opacity: 1;
}

@media (min-width: 1440px) {
  .hero .hero-content {
    grid-template-columns: calc(var(--gutter) + 510px) minmax(0, 1fr);
  }
}

.hero .hero-text .hero-label {
  margin: 0 0 var(--space-xs);
}

.hero-label::after {
  content: "";
  display: block;
  width: 42px;
  height: 2px;
  margin-top: var(--space-xs);
  background: var(--color-orange);
}

@media (max-width: 1000px) {
  .hero .hero-text { padding: var(--hero-padding-block) var(--space-m); }
  .button { max-width: 100%; text-align: center; }

  .hero .hero-content {
    position: relative;
    display: block;
    isolation: isolate;
    overflow: hidden;
  }

  .hero .hero-content .hero-text {
    position: relative;
    color: white;
  }

  .hero .hero-content .hero-image {
    position: static;
    min-height: 0;
    border-radius: 0;
    clip-path: none;
    overflow: visible;
  }

  .hero .hero-content .hero-image .hero-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0;
    clip-path: none;
    transform: none;
    z-index: -2;
  }

  .hero .hero-content .hero-image::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgb(0 0 0 / var(--hero-shade));
    border-radius: 0;
    clip-path: none;
    z-index: -1;
  }
}

:is(.button, button):not(.scroll-top, .cookie-settings-link, .close-cookie, .close-contact, .menu-button, .store-buttons button, .newsletter button):not(:disabled):not([aria-disabled="true"]) {
  background-image: linear-gradient(var(--button-fill, var(--color-button-hover)), var(--button-fill, var(--color-button-hover)));
  background-size: 0% 100%;
  background-position: left center;
  background-repeat: no-repeat;
  background-origin: border-box;
  background-clip: border-box;
  transition: background-size 360ms cubic-bezier(.22, .61, .36, 1), border-color 180ms ease, color 180ms ease;

  &:is(:hover, :focus-visible) {
    background-size: 100% 100%;
    border-color: var(--color-button-hover);
    color: white;
  }

  &:active {
    --button-fill: var(--color-button-pressed);
    background-color: var(--color-button-pressed);
    background-size: 100% 100%;
    border-color: var(--color-button-pressed);
    color: white;
    transition-duration: 0s;
  }
}

body :is(.close-cookie, .close-contact) {
  transition: color 180ms ease;
}
body :is(.close-cookie, .close-contact):is(:hover, :focus-visible) {
  color: var(--color-button-hover);
}
body :is(.close-cookie, .close-contact):active {
  color: var(--color-button-pressed);
}

.header .menu-button {
  transition: background-color 120ms ease, border-color 120ms ease;
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) and (pointer: fine) {
  .header .menu-button:hover {
    background-color: var(--color-button-hover);
    border-color: var(--color-button-hover);
  }
  .header .menu-button:hover img { filter: brightness(0) invert(1); }
}
.header .menu-button:active {
  background-color: var(--color-button-pressed);
  border-color: var(--color-button-pressed);
  transition-duration: 0s;
}
.header .menu-button:active img { filter: brightness(0) invert(1); }
