/**
 * @file
 * Structural CSS for Marine Components theme.
 * 
 * This file contains layout and structural styles that supplement
 * the designer's styles.css. The designer's CSS is not modified.
 */

/* =============================================================================
   1. CSS CUSTOM PROPERTIES
   ============================================================================= */

:root {
  /* Breakpoints */
  --bp-sm: 576px;
  --bp-md: 768px;
  --bp-lg: 992px;
  --bp-xl: 1200px;
  --bp-xxl: 1400px;
  
  /* Colors from designer */
  --color-primary: #366d80;
  --color-primary-dark: #0d273e;
  --color-primary-darker: #194071;
  --color-secondary: #1e6d82;
  --color-accent: #20406d;
  --color-text: #1f1f1f;
  --color-white: #fff;
  --color-grey-light: #f4f4f4;
  --color-grey-border: #ccc;
  --color-grey-dark: #bbbbbb;
  
  /* Spacing scale (8px base) */
  --space-xs: 5px;
  --space-sm: 10px;
  --space-md: 15px;
  --space-lg: 20px;
  --space-xl: 30px;
  --space-2xl: 40px;
  --space-3xl: 50px;
  --space-4xl: 75px;
  
  /* Z-index scale */
  --z-base: 1;
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 9998;
  --z-modal: 9999;
  --z-skip-link: 10000;
  
  /* Focus indicator */
  --focus-outline: 2px solid var(--color-primary);
  --focus-outline-offset: 2px;
}

/* =============================================================================
   1.5. GLOBAL LAYOUT FIXES
   ============================================================================= */

/* Prevent horizontal overflow/scrolling */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

#page {
  overflow-x: hidden;
  max-width: 100%;
}

/* Video Masthead - full viewport width */
.masthead {
  width: 100vw;
  max-width: 100vw;
  margin-left: calc(-50vw + 50%);
  position: relative;
  left: 0;
}

/* Ensure video fills masthead */
.masthead video {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}

/* Video toggle button */
.video-toggle-btn {
  position: absolute;
  bottom: var(--space-lg);
  right: var(--space-lg);
  background: rgba(0, 0, 0, 0.6);
  color: var(--color-white);
  border: none;
  padding: var(--space-sm) 14px;
  font-size: 18px;
  cursor: pointer;
  border-radius: 4px;
  z-index: var(--z-base);
  transition: background 0.3s ease;
}

.video-toggle-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

.video-toggle-btn:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-outline-offset);
}

/* Video wrapper for positioning context on mobile */
.masthead-video-wrapper {
  position: relative;
}

/* On mobile, position video toggle relative to video wrapper, not masthead */
@media (max-width: 768px) {
  .video-toggle-btn {
    bottom: var(--space-md, 16px);
    right: var(--space-md, 16px);
  }
}

/* Fix main content to not constrain masthead */
main#main-content {
  overflow: visible;
}

/* =============================================================================
   2. ACCESSIBILITY
   ============================================================================= */

/* Skip Link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-primary-dark);
  color: var(--color-white);
  padding: 8px 16px;
  z-index: var(--z-skip-link);
  text-decoration: none;
  font-weight: bold;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
}

/* Focus States */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-outline-offset);
}

/* Additional focus states for interactive components */
.bucket-one:focus-visible,
.carousel-btn:focus-visible,
.video-poster:focus-visible,
.play-button:focus-visible,
.faqitem .header:focus-visible,
.thumb:focus-visible,
.label:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-outline-offset);
}

/* Screen Reader Only */
.sr-only,
.visually-hidden {
  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;
}

.visually-hidden.focusable:focus {
  position: static !important;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  overflow: visible !important;
  clip: auto !important;
  white-space: normal !important;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* =============================================================================
   3. ADMIN TOOLBAR ADJUSTMENTS
   ============================================================================= */

body.toolbar-fixed .header-stuff {
  position: relative;
}

/* =============================================================================
   4. DRUPAL-SPECIFIC FIXES
   ============================================================================= */

/* Remove default field wrappers */
.field {
  margin: 0;
  padding: 0;
}

.field__label {
  display: none;
}

/* Paragraph spacing reset */
.paragraph {
  margin-bottom: 0;
}

/* Messages */
.messages {
  padding: 15px 20px;
  margin-bottom: 20px;
  border-radius: 4px;
}

.messages--status {
  background-color: #d4edda;
  border: 1px solid #c3e6cb;
  color: #155724;
}

.messages--warning {
  background-color: #fff3cd;
  border: 1px solid #ffeeba;
  color: #856404;
}

.messages--error {
  background-color: #f8d7da;
  border: 1px solid #f5c6cb;
  color: #721c24;
}

/* =============================================================================
   5. FORM ERROR STATES
   ============================================================================= */

.form-item--error input,
.form-item--error select,
.form-item--error textarea {
  border-color: #dc3545;
  box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.25);
}

.form-item__error-message {
  color: #dc3545;
  font-size: 14px;
  margin-top: 5px;
}

.form-required::after {
  content: " *";
  color: #dc3545;
}

/* =============================================================================
   6. LAYOUT UTILITIES
   ============================================================================= */

.clearfix::after {
  content: "";
  display: table;
  clear: both;
}

/* Full-width breakout */
.full-width {
  width: 100vw;
  max-width: 100vw;
  margin-left: calc(-50vw + 50%);
  position: relative;
}

/* =============================================================================
   7. HEADER FIXES
   ============================================================================= */

/* Logo - ensure image displays properly */
a.logo {
  background: none !important;
  text-indent: 0 !important;
}

a.logo img {
  max-width: 155px;
  height: auto;
  display: block;
}

/* Fix nested Drupal nav inside header nav ul - flatten it */
.header-stuff > nav > ul > nav {
  display: contents;
}

.header-stuff > nav > ul > nav > ul {
  display: contents;
}

/* Ensure nav list items don't have bullet styling */
.header-stuff nav ul li {
  background: none;
  padding-left: 0;
  list-style: none;
}

/* Search and menu container for mobile - float right to match designer pattern */
.search-and-menu {
  float: right;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 15px;
  margin-right: 15px;
}

/* Hamburger button */
.mm-open-btn {
  display: inline-block;
  vertical-align: middle;
}

/* Search dropdown styling */
.search-spot {
  position: relative;
}

.search-spot .infopage {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--color-white);
  border: 1px solid var(--color-grey-border);
  border-top: 5px solid var(--color-primary-darker);
  padding: var(--space-md);
  min-width: 280px;
  z-index: var(--z-dropdown);
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.search-spot .infopage:not([hidden]) {
  display: block;
}

.search-spot .search-form {
  display: flex;
  gap: 10px;
}

.search-spot .input-text {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--color-grey-border);
  font-size: 14px;
}

.search-spot .action.search {
  padding: 8px 16px;
  background: var(--color-primary-darker);
  color: var(--color-white);
  border: none;
  cursor: pointer;
  font-weight: bold;
}

/* Search toggle button styling */
.search-toggle.linkbutton {
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-xs);
}

.search-toggle.linkbutton svg {
  fill: var(--color-primary-darker);
  display: block;
}

/* Mobile responsive header */
@media (max-width: 680px) {
  /* Hide desktop utility menu on mobile */
  header > .utility-menu {
    display: none;
  }
  
  .header-stuff > nav {
    display: none; /* Hide desktop nav on mobile */
  }
  
  .search-and-menu {
    float: right;
    margin-top: 10px;
  }
  
  /* Ensure footer nav is always visible on mobile */
  footer nav,
  footer .footer-nav,
  footer .footer-nav nav,
  nav.footer-nav,
  nav.footer-nav nav {
    display: block !important;
  }
}

@media (min-width: 1060px) {
  /* Hide mobile search/hamburger on desktop */
  .search-and-menu {
    display: none !important;
  }
  
  /* Show desktop utility menu with flexbox layout */
  header > .utility-menu {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  
  /* Ensure desktop nav is visible */
  .header-stuff > nav {
    display: block;
  }
}
