// Removed: .retro-tab, .retro-tab-list and .retro-nav-tabs. All three were
// orphaned styling for a tab markup nothing used -- tabs.js drives
// .retro-tab-content and .retro-tab-pane, every page uses .retro-nav-tabbed,
// and the documentation never mentioned them.
/* Retro Nav - Win9x Style Only */

@use "../variables" as *;
@use "../mixins" as *;

/**
 * @name Retro Navigation
 * @group components
 * @description
 * Navigation component with various styles and variants.
 * @example scss
 *   <nav class="retro-nav">
 *     <a href="#" class="retro-nav-item">Home</a>
 *     <a href="#" class="retro-nav-item">About</a>
 *     <a href="#" class="retro-nav-item">Contact</a>
 *   </nav>
 */

.retro-nav {
  display: flex;
  flex-wrap: wrap;
  padding: 0;
  margin: 0;
  list-style: none;
  background: var(--retro-light);
  border: 2px solid var(--retro-border-dark);
  border-radius: var(--retro-border-radius);
  box-shadow: inset 1px 1px 0 var(--retro-border-light), inset -1px -1px 0 var(--retro-border-medium);
  font-family: var(--retro-font);
  transition: none;
}

.retro-nav-item {
  display: inline-block;
  padding: $retro-spacing-sm $retro-spacing-md;
  color: var(--retro-black);
  text-decoration: none;
  border-radius: var(--retro-border-radius);
  background: var(--retro-light);
  border-right: 1px solid var(--retro-border-medium);
  font-family: var(--retro-font);
  transition: none;

  &:hover {
    background: var(--retro-light);
    color: var(--retro-primary-text);
  }

  // [aria-current] as well as .active: marking the current page the accessible
  // way should not cost you the highlight.
  &.active,
  &[aria-current]:not([aria-current="false"]) {
    background: var(--retro-primary);
    color: var(--retro-primary-fg);
    text-shadow: 0 1px 2px var(--retro-border-dark), 0 0 2px var(--retro-border-light);
    outline: 2px solid var(--retro-border-light);
    outline-offset: -2px;
  }

  &:focus-visible {
    z-index: 2;
  }

  @include retro-focus-ring($width: 2px);
}

// .retro-tab is an alias for .retro-nav-item, used for tabbed navigation

// --- Vertical Nav Variant ---
.retro-nav-vertical {
  display: flex;
  flex-direction: column;
  // max-content sizes to the longest label, which overflowed narrow viewports.
  width: max-content;
  max-width: 100%;
  border: 2px solid var(--retro-border-dark);
  background: var(--retro-light);
  padding: 0;
  margin: 0;
  list-style: none;
  box-shadow: inset 1px 1px 0 var(--retro-border-light), inset -1px -1px 0 var(--retro-border-medium);
}

.retro-nav-vertical .retro-nav-item {
  display: block;
  border-inline-end: none;
  border-bottom: 1px solid var(--retro-border-medium);
  border-radius: var(--retro-border-radius);
  width: 100%;
  &:last-child {
    border-bottom: none;
  }
}

// --- Pills Nav Variant ---
.retro-nav-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
}

.retro-nav-pills .retro-nav-item {
  // Deliberately not var(--retro-border-radius): a pill is the shape the
  // component is named for, and this is the one place the framework spends
  // a modern idiom on purpose. Allowlisted in scripts/check-radius.mjs.
  border-radius: 999px;
  background: var(--retro-light);
  border: 1px solid var(--retro-border-medium);
  margin: 0 2px;
  padding: $retro-spacing-sm $retro-spacing-lg;
  transition: background 0.2s, color 0.2s;
  color: var(--retro-black);
  &:hover {
    background: var(--retro-primary);
    color: var(--retro-primary-fg);
  }
  &.active {
    background: var(--retro-primary);
    color: var(--retro-primary-fg);
    font-weight: bold;
    box-shadow: 0 1px 4px rgba(var(--retro-primary-rgb), 0.35) inset;
  }
}

// --- Win9x Style Tabs ---

// --- Toolbar-style Navigation ---
.retro-nav-toolbar {
  display: flex;
  flex-wrap: wrap;
  padding: 2px;
  margin: 0;
  background: var(--retro-light);
  border: 2px solid var(--retro-border-dark);
  border-radius: var(--retro-border-radius);
  box-shadow: inset 1px 1px 0 var(--retro-border-light), inset -1px -1px 0 var(--retro-border-medium);
  font-family: var(--retro-font);
  
  .retro-nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 2px 10px;
    margin: 2px;
    color: var(--retro-black);
    text-decoration: none;
    background: var(--retro-light);
    border: 2px solid transparent;
    border-radius: var(--retro-border-radius);
    text-align: center;
    
    &:hover {
      background: var(--retro-white);
      border: 2px solid var(--retro-border-medium);
      border-right: 2px solid var(--retro-border-dark);
      border-bottom: 2px solid var(--retro-border-dark);
      border-left: 2px solid var(--retro-border-light);
      border-top: 2px solid var(--retro-border-light);
    }
    
    &.active {
      background: var(--retro-light);
      border: 2px solid var(--retro-border-medium);
      border-right: 2px solid var(--retro-border-light);
      border-bottom: 2px solid var(--retro-border-light);
      border-left: 2px solid var(--retro-border-dark);
      border-top: 2px solid var(--retro-border-dark);
      color: var(--retro-black);
      font-weight: normal;
    }
    
    .retro-nav-icon {
      font-size: var(--retro-font-size-xl);
      margin-inline-end: 4px;
    }
  }
  
  &.retro-nav-icons .retro-nav-item {
    width: 36px;
    padding: 0;
    
    .retro-nav-icon {
      margin-inline-end: 0;
    }
  }
  
  .retro-nav-separator {
    width: 1px;
    height: 30px;
    margin: 3px 4px;
    background: var(--retro-border-medium);
    box-shadow: 1px 0 0 var(--retro-border-light);
  }
}

// --- Tabbed Navigation ---
.retro-nav-tabbed {
  display: flex;
  // Wrap rather than push the page wide. A nav is a list of labels of
  // unknown length, and a single flex row of them was the largest source
  // of horizontal overflow on narrow viewports.
  flex-wrap: wrap;
  padding: 0;
  margin: 0 0 -1px 0;
  background: transparent;
  border: 0;
  border-bottom: 2px solid var(--retro-border-dark);
  box-shadow: none;
  position: relative;
  z-index: 1;
  
  .retro-nav-item {
    padding: 8px 16px;
    background: var(--retro-light);
    border: 2px solid var(--retro-border-dark);
    border-bottom: 0;
    margin-inline-end: 2px;
    position: relative;
    box-shadow: inset 1px 1px 0 var(--retro-border-light);
    color: var(--retro-black);
    
    &:hover {
      background: var(--retro-white);
      color: var(--retro-black);
    }
    
    &.active {
      background: var(--retro-white);
      color: var(--retro-black);
      border-bottom: 2px solid var(--retro-white);
      z-index: 2;
      margin-bottom: -2px;
    }
  }
}

// --- Underlined Navigation ---
.retro-nav-underlined {
  display: flex;
  // Wrap rather than push the page wide. A nav is a list of labels of
  // unknown length, and a single flex row of them was the largest source
  // of horizontal overflow on narrow viewports.
  flex-wrap: wrap;
  padding: 0;
  margin: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  border-bottom: 1px solid var(--retro-border-medium);
  
  .retro-nav-item {
    padding: 10px 16px;
    background: transparent;
    border: none;
    position: relative;
    margin-inline-end: 4px;
    color: var(--retro-black);
    
    &:after {
      content: '';
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      height: 3px;
      background: transparent;
    }
    
    &:hover {
      background: transparent;
      color: var(--retro-primary-text);
      
      &:after {
        background: rgba(var(--retro-primary-rgb), 0.3);
      }
    }
    
    &.active {
      background: transparent;
      color: var(--retro-primary-text);
      font-weight: normal;
      
      &:after {
        background: var(--retro-primary);
      }
    }
  }
}

// --- Button Group Navigation ---
.retro-nav-buttons {
  display: inline-flex;
  // Wrap rather than push the page wide. A nav is a list of labels of
  // unknown length, and a single flex row of them was the largest source
  // of horizontal overflow on narrow viewports.
  flex-wrap: wrap;
  padding: 0;
  margin: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  
  .retro-nav-item {
    padding: 6px 14px;
    background: var(--retro-light);
    border: 2px solid var(--retro-border-dark);
    border-right: 1px solid var(--retro-border-dark);
    border-left: 1px solid var(--retro-border-dark);
    margin: 0;
    position: relative;
    box-shadow: inset 1px 1px 0 var(--retro-border-light), inset -1px -1px 0 var(--retro-border-medium);
    color: var(--retro-black);
    
    &:first-child {
      border-left: 2px solid var(--retro-border-dark);
      border-top-left-radius: var(--retro-border-radius);
      border-bottom-left-radius: var(--retro-border-radius);
    }
    
    &:last-child {
      border-right: 2px solid var(--retro-border-dark);
      border-top-right-radius: var(--retro-border-radius);
      border-bottom-right-radius: var(--retro-border-radius);
    }
    
    &:hover {
      background: var(--retro-white);
      color: var(--retro-black);
      z-index: 1;
    }
    
    &.active {
      background: var(--retro-primary);
      color: var(--retro-primary-fg);
      z-index: 2;
    }
  }
}

/**
 * @name Tab Panes
 * @group components
 * @description
 * Panel bodies for the tabbed / underlined / button nav variants. Referenced by
 * the demos but never defined, so tab content rendered unstyled and every pane
 * stayed visible at once.
 */
.retro-tab-pane {
  display: none;
  padding: var(--retro-spacing-md);
  background: var(--retro-bg);
  color: var(--retro-text);
  border: var(--retro-border-width-thick) solid var(--retro-border-dark);
  border-top: none;

  &.active { display: block; }
}

// The underlined and button navs have no boxed body, so their panes lose the frame.
.retro-tab-pane-underlined,
.retro-tab-pane-buttons {
  border: none;
  padding: var(--retro-spacing-md) 0;
  background: transparent;
}
