/*
 * UL Design System — documentation site styles.
 *
 * Colours and fonts are PoC values that will be replaced once
 * packages/brand-uls is compiled and its CSS custom properties
 * are available. Placeholders are marked with TODO.
 */

/* -----------------------------------------------------------------------
   Custom properties (TODO: replace with compiled brand token imports)
----------------------------------------------------------------------- */
:root {
  --ds-color-brand:         #003A70;
  --ds-color-brand-mid:     #005191;
  --ds-color-brand-light:   #e8f0f8;
  --ds-color-accent:        #DA291C;
  --ds-color-text:          #1a2332;
  --ds-color-text-subtle:   #6b7280;
  --ds-color-bg:            #ffffff;
  --ds-color-surface:       #f8f9fa;
  --ds-color-border:        #e5e7eb;
  --ds-color-nav-bg:        #f3f4f6;
  --ds-font-body:           'Open Sans', system-ui, -apple-system, sans-serif;
  --ds-font-heading:        'Poppins', system-ui, -apple-system, sans-serif;
  --ds-font-mono:           'Menlo', 'Consolas', 'Monaco', monospace;
  --ds-header-height:       56px;
  --ds-nav-width: 18rem;
  --ds-content-max-width:   780px;
}

/* -----------------------------------------------------------------------
   Reset & base
----------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  height: 100%;
  width: 100%;
}

body {
  font-family: var(--ds-font-body);
  height: 100%;
    width: 100%;
    display: grid;
    grid-template-areas: "header header" "nav main";
    grid-template-columns: min-content 1fr;
    grid-template-rows: min-content 1fr;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--ds-color-text);
  background: var(--ds-color-bg);
}

hr {
  margin: 1rem 0 1rem 1rem;
  border-color: transparent;
}

ul-app-header {
  grid-area: header;
  z-index: 100;
}

ul-app-header nav {
  display: flex;
  gap: 0.5rem;
}
/* -----------------------------------------------------------------------
   Skip link (accessibility)
----------------------------------------------------------------------- */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  padding: 8px 16px;
  background: var(--ds-color-brand);
  color: #fff;
  font-size: 0.875rem;
  text-decoration: none;
  z-index: 200;
  transition: top 0.1s;
}
.skip-link:focus { top: 0; }

/* Top nav links */
.storybook-link {
  font-size: 0.75rem;
  text-decoration: none;
  padding: 0.2rem 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.storybook-link:hover {
}

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}

/* -----------------------------------------------------------------------
   Layout shell
----------------------------------------------------------------------- */
.site-layout {
  display: flex;
  min-height: calc(100vh - var(--ds-header-height));
}

/* -----------------------------------------------------------------------
   Sidebar nav
----------------------------------------------------------------------- */
.site-nav {
  width: var(--ds-nav-width);
  flex-shrink: 0;
  background: var(--ds-color-nav-bg);
  border-right: 1px solid var(--ds-color-border);
  padding: 1.5rem 0 2rem;
  position: sticky;
  top: var(--ds-header-height);
  height: calc(100vh - var(--ds-header-height));
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

.nav-section {
  margin-bottom: 0;
  border-bottom: 1px solid var(--ds-color-border);
}

.nav-section-title {
  font-family: var(--ds-font-heading);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ds-color-text-subtle);
  padding: 0.625rem 1.25rem;
  cursor: pointer;
  list-style: none; /* remove default triangle in Firefox */
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

/* Remove default marker */
.nav-section-title::-webkit-details-marker { display: none; }

/* Custom chevron */
.nav-section-title::after {
  content: '';
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.15s;
  flex-shrink: 0;
}

.nav-section[open] > .nav-section-title::after {
  transform: rotate(-135deg);
}

.nav-section ul {
  list-style: none;
  padding-bottom: 0.5rem;
}

.nav-section a {
  display: block;
  padding: 0.375rem 1.25rem 0.375rem 1.125rem;
  font-size: 0.875rem;
  color: var(--ds-color-text);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}

.nav-section a:hover {
  background: var(--ds-color-border);
  color: var(--ds-color-brand);
}

.nav-section a[aria-current="page"] {
  color: var(--ds-color-brand);
  border-left-color: var(--ds-color-brand);
  background: var(--ds-color-brand-light);
  font-weight: 600;
}

/* Section header link — must come after .nav-section a to win the cascade */
.nav-section-title > a {
  display: inline;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: var(--ds-color-link, #006fce);
  border-left: none;
  text-decoration: none;
  background: none;
}

.nav-section-title > a:hover {
  background: none;
  text-decoration: underline;
}

/* -----------------------------------------------------------------------
   Main content
----------------------------------------------------------------------- */
div#main-content {
  overflow:auto;
}

main {
  flex: 1;
  min-width: 0;
  max-width: var(--ds-content-max-width);
  padding: 2.5rem 3rem;

  p {
    margin-bottom: 1rem;
    max-width: 68ch;
  }

  img {
    zoom: 0.5;
    max-width: 100%;
  }
  
  a {
    color: var(--ds-color-brand-mid);
  }
  a:hover {
    text-decoration: none;
  }
  ul,
  ol {
    margin: 0 0 1rem 1.5rem;
  }
  li {
    margin-bottom: 0.3rem;
  }
  code {
    font-family: var(--ds-font-mono);
    font-size: 0.875em;
    background: var(--ds-color-surface);
    border: 1px solid var(--ds-color-border);
    padding: 0.1em 0.35em;
    border-radius: 3px;
  }
  pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 1.25rem 1.5rem;
    border-radius: 6px;
    overflow-x: auto;
    margin: 1.25rem 0;
    line-height: 1.55;
  }
  pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.875rem;
    color: inherit;
  }
  blockquote {
    margin: 1.25rem 0;
    padding: 0.75rem 1.25rem;
    border-left: 4px solid var(--ds-color-brand-mid);
    background: var(--ds-color-surface);
    color: var(--ds-color-text-subtle);
  }
  table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.25rem 0;
    font-size: 0.875rem;
  }
  th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    background: var(--ds-color-surface);
    border-bottom: 2px solid var(--ds-color-border);
    font-family: var(--ds-font-heading);
    font-weight: 600;
    font-size: 0.8125rem;
  }
  td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--ds-color-border);
    vertical-align: top;
  }
  tr:last-child td {
    border-bottom: none;
  }
  hr {
    border: none;
    border-top: 1px solid var(--ds-color-border);
    margin: 2rem 0;
  }
}

/* -----------------------------------------------------------------------
   Responsive
----------------------------------------------------------------------- */
@media (max-width: 900px) {
  .storybook-nav-label,
  .storybook-link:nth-child(n+3) {
    display: none;
  }
}

@media (max-width: 768px) {
  .nav-toggle {
    display: flex;
  }

  .storybook-nav {
    display: none;
  }

  .site-nav {
    grid-area: nav;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.15);
  }

  .site-nav.is-open {
    transform: translateX(0);
  }

  .site-content {
    padding: 1.5rem 1.25rem;
  }

  .page-title {
    font-size: 1.625rem;
  }
}

/* -----------------------------------------------------------------------
   Standalone home nav link
----------------------------------------------------------------------- */
.nav-home-link {
  display: block;
  padding: 0.75rem 1.25rem;
  font-family: var(--ds-font-heading);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ds-color-text);
  text-decoration: none;
  border-bottom: 1px solid var(--ds-color-border);
}

.nav-home-link:hover {
  background: var(--ds-color-border);
  color: var(--ds-color-brand);
}

.nav-home-link[aria-current="page"] {
  color: var(--ds-color-brand);
  background: var(--ds-color-brand-light);
}

/* -----------------------------------------------------------------------
   Homepage grid
----------------------------------------------------------------------- */
.home-tagline {
  font-size: 1.125rem;
  color: var(--ds-color-text-subtle);
  margin-bottom: 2.5rem !important;
  max-width: 56ch;
}

.home-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.home-card {
  display: block;
  border: 1px solid var(--ds-color-border);
  border-radius: 6px;
  width: 200px;
  text-decoration: none;
  color: inherit;
  background: var(--ds-color-bg);
  overflow: hidden;
  transition: box-shadow 0.15s, border-color 0.15s;
}

a.home-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  border-color: var(--ds-color-brand-mid);
}

.home-card-image {
  height: 130px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: var(--ds-color-surface);
}

.home-card-label {
  padding: 0.625rem 0.875rem;
  font-size: 0.9375rem;
  font-weight: 500;
  border-top: 1px solid var(--ds-color-border);
}

.home-card--draft {
  opacity: 0.45;
  cursor: default;
}

.storybook-embed {
  width: 1200px;
}