/**
 * Equinor Design System - Docusaurus Custom CSS
 * 
 * This file contains custom styling for the Equinor Design System documentation
 * built with Docusaurus. It overrides Infima variables (Docusaurus default styling)
 * and applies EDS styling to various components.
 */

/* ======================================
 * FONTS
 * ====================================== */
/* Equinor brand font */
@import '@equinor/eds-tokens/css/variables-static';
@import url(https://cdn.eds.equinor.com/font/equinor-font.css);
/* TODO: This needs to be imported from Equinor CDN later */
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');

/* ======================================
 * ROOT VARIABLES - LIGHT THEME
 * ====================================== */
:root,
[data-theme='light'] {
  color-scheme: light;
}

[data-theme='dark'] {
  color-scheme: dark;
}

:root {
  /* Typography */
  --ifm-font-family-base: 'Inter';
  --ifm-heading-font-family: 'Equinor';
  --ifm-font-color-base: var(--eds-color-text-neutral-strong);

  /* Primary colors based on EDS accent */
  --ifm-color-primary: var(--eds-color-bg-accent-fill-emphasis-default);
  --ifm-color-primary-dark: var(--eds-color-bg-accent-fill-emphasis-hover);
  --ifm-color-primary-darker: var(--eds-color-bg-accent-fill-emphasis-active);
  --ifm-color-primary-darkest: var(--eds-color-bg-accent-fill-emphasis);
  --ifm-color-primary-light: var(--eds-color-bg-accent-fill-muted-active);
  --ifm-color-primary-lighter: var(--eds-color-bg-accent-fill-muted-hover);
  --ifm-color-primary-lightest: var(--eds-color-bg-accent-fill-muted-default);

  /* Background and surface colors */
  --ifm-background-color: var(--eds-color-bg-neutral-canvas);
  --ifm-background-surface-color: var(--eds-color-bg-neutral-surface);
  --ifm-code-font-size: 95%;

  /* General UI elements */
  --ifm-hover-overlay: var(--eds-color-bg-accent-fill-muted-default);
  --ifm-global-radius: 4px;
  --docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.1);

  /* Navbar styling */
  --ifm-navbar-height: 68px;
  --ifm-navbar-link-color: var(--ifm-font-color-base);
  --ifm-navbar-link-hover-color: var(--ifm-font-color-base);
  --ifm-navbar-padding-vertical: 0;
  --ifm-navbar-item-padding-vertical: 0;
  --ifm-navbar-item-padding-horizontal: 1.5rem;

  /* Menu and sidebar styling */
  --ifm-menu-color: var(--ifm-font-color-base);
  --ifm-menu-color-active: var(--ifm-color-primary);
  --ifm-menu-color-background-active: var(--ifm-hover-overlay);
  --ifm-menu-color-background-hover: var(--ifm-hover-overlay);
  --ifm-menu-link-padding-horizontal: 1rem;
  --ifm-menu-link-padding-vertical: 0.375rem;
  --ifm-menu-link-sublist-icon-filter: none;

  /* Table of contents */
  --ifm-toc-padding-vertical: 0;
  --ifm-toc-padding-horizontal: 0;

  /* Breadcrumbs and footer */
  --ifm-breadcrumb-separator: '';
  --ifm-footer-padding-vertical: 1rem;
  --ifm-footer-padding-horizontal: 1rem;
}

/* ======================================
 * GLOBAL STYLES
 * ====================================== */
* {
  transition:
    color 200ms ease-in,
    background-color 200ms ease-in,
    border 200ms ease-in;
}

/* ======================================
 * SIDEBAR NAVIGATION
 * ====================================== */
nav.menu {
  background-color: var(--ifm-background-surface-color);
  border-right: var(--eds-color-border-neutral-subtle) 1px solid;
  padding: 0;
  /* UIBody - MD */
  font-size: 0.875rem;
  line-height: 0.75rem;
}

nav.menu .menu__list {
  margin-top: 0;
  padding: 0;
}

nav.menu li {
  margin-top: 0;
}

.menu__list-item:not(:first-child) {
  margin-top: 0;
}

.menu__link--active {
  background-color: var(--ifm-hover-overlay) !important;
}

/* Sidebar menu items styling */
nav.menu li div {
  border-radius: 0;
}

nav.menu li a {
  border-radius: 0;
  padding: 1rem;
}

.theme-doc-sidebar-item-link-level-2 a {
  padding-left: 2rem !important;
}

/* ======================================
 * TOP NAVIGATION BAR
 * ====================================== */
.navbar {
  box-shadow: unset;
  border-bottom: var(--eds-color-border-neutral-subtle) 1px solid;
}

.navbar__brand {
  font-family: 'Equinor', sans-serif;
}

.navbar__item {
  padding: 1.75rem 1.5rem;
  /* UIBody - MD */
  font-size: 0.875rem;
  line-height: 0.75rem;
  box-shadow: 0px -1px 0px 0px var(--eds-color-border-neutral-subtle) inset;
  transition:
    box-shadow 150ms,
    background-color 150ms;
}

.navbar__item:hover {
  background-color: var(--ifm-hover-overlay);
  color: var(----ifm-font-color-base);
}

.navbar__link--active {
  box-shadow: 0px -2px 0px 0px var(--ifm-color-primary) inset;
}

/* ======================================
 * MAIN CONTENT AREA
 * ====================================== */
.theme-doc-markdown {
  padding: 1.5rem;
  background-color: var(--ifm-background-surface-color);
  border: var(--eds-color-border-neutral-subtle) 1px solid;
  border-radius: var(--ifm-global-radius);
}

/* ======================================
 * STORYBOOK IFRAME
 * ====================================== */

.sb-iframe {
  border: var(--eds-color-border-neutral-subtle) 1px solid;
  border-radius: var(--ifm-global-radius);
  background-color: var(--eds-color-bg-neutral-surface);
}

/* ======================================
 * TABLE OF CONTENTS
 * ====================================== */
.theme-doc-toc-desktop {
  margin: 3rem 0 0 0;
}

.theme-doc-toc-desktop ul li ul .table-of-contents__link {
  padding: 0.5rem 3rem;
}

.table-of-contents__link {
  padding: 0.5rem 2rem;
  transition: background-color 150ms ease-in-out;
  position: relative;
}

.table-of-contents__link:hover {
  background-color: var(--ifm-hover-overlay);
}

.table-of-contents__link--active {
  background-color: var(--ifm-hover-overlay) !important;
  position: relative;
}

/* Left border indicator for active TOC item */
.table-of-contents__link:before {
  position: absolute;
  top: 0;
  left: 0;
  content: '';
  background-color: rgba(0, 0, 0, 0);
  height: 100%;
  width: 4px;
  transition: background-color 150ms ease-in-out;
}

.table-of-contents__link--active:before {
  background-color: var(--ifm-color-primary);
}

/* ======================================
 * BREADCRUMBS
 * ====================================== */
.theme-doc-breadcrumbs .breadcrumbs__item:not(:last-child):after {
  content: '/';
}

.theme-doc-breadcrumbs .breadcrumbs__item .breadcrumbs__link {
  background-color: unset;
}

/* ======================================
 * FOOTER
 * ====================================== */
.footer {
  background-color: var(--ifm-color-primary);
  color: var(--eds-color-text-accent-strong-on-emphasis);
}

.footer__container {
  display: flex;
  width: 100%;
  max-width: none;
  justify-content: space-between;
}

.footer__links {
  margin: 0;
}

.footer-links__group {
  list-style: none;
  display: flex;
  padding: 0;
  margin: 0;
  width: fit-content;
  gap: 0.5rem;
}

.footer-links__link {
  border-radius: var(--ifm-global-radius);
  color: var(--eds-color-text-accent-strong-on-emphasis);
  transition: background-color 150ms ease-in-out;
  display: block;
  padding: 0.25rem;
}
.footer-links__link:hover {
  color: var(--eds-color-text-accent-strong-on-emphasis);
  transition: background-color 150ms ease-in-out;
  display: block;
  background-color: var(--eds-color-bg-accent-fill-emphasis-hover);
}
.footer-links__link svg {
  fill: var(--eds-color-text-accent-strong-on-emphasis);
  display: block;
}
