/* 
 * Shift + Alt Events Partner Network — Master Design System & Stylesheet
 * Purpose: Defines the strict monochrome visual system, typography hierarchy, signature two-part heading device,
 * responsive navigation shell, mobile drawer, toast notifications, cards, and error states.
 * THE STYLE GUIDE IS LAW: Strictly zero border-radius anywhere. No red error colors.
 */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;1,300;1,400&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,400&display=swap');

/* --- 1. Global Reset & Hard Architectural Constraints --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  /* LAW: No rounded corners anywhere, ever. */
  border-radius: 0 !important;
}

:root {
  /* Tier 1: Primitives (Strictly black, white, and grey palette per Style Guide) */
  --color-black: #000000;
  --color-white: #ffffff;
  --color-paper: #f6f6f6;
  --color-hairline: #e0e0e0;
  --color-rule: #d0d0d0;
  --color-muted: #767676;
  --color-placeholder: #a8a8a8;
  --color-separator: #999999;
  --color-error: #000000; /* Stays black by default to preserve monochrome integrity */

  /* Typography tokens (Style Guide Law) */
  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'DM Sans', Arial, sans-serif;

  /* Mathematical Spacing Scale (DTCG format) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-16: 64px;

  /* Tier 2: Semantic Tokens */
  --surface-default: var(--color-white);
  --surface-panel: var(--color-paper);
  --surface-hover: #ebebeb;
  --border-subtle: var(--color-hairline);
  --border-default: var(--color-rule);
  --border-strong: var(--color-black);
  --text-primary: var(--color-black);
  --text-secondary: var(--color-muted);

  /* Tier 3: Component & Sizing tokens */
  --gap-base: 28px;
  --max-width: 1240px;
  --sidebar-width: 260px;
  --header-height: 72px;
  --card-padding: 32px;
  --btn-height: 52px;
  --focus-ring: 2px solid var(--color-black);

  /* Transitions (Functional minimalist timing) */
  --transition-fast: 0.18s ease;
  --transition-functional: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

html, body {
  background-color: var(--color-white);
  color: var(--color-black);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
  transition: opacity var(--transition-fast), color var(--transition-fast);
}

/* WCAG 2.2 AA High-Contrast Focus Indicators */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.terr-tab:focus-visible,
.cat-pill:focus-visible,
.palette-item:focus-visible {
  outline: var(--focus-ring) !important;
  outline-offset: 3px !important;
}

img, svg {
  max-width: 100%;
  display: block;
}

/* --- 2. Typography & Signature Two-Part Heading Device --- */
.heading-display {
  font-family: var(--font-serif);
  font-size: clamp(34px, 5vw, 52px);
  font-weight: 300;
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--color-black);
  margin-bottom: 12px;
}

.heading-display em,
.heading-display .italic-qualifier {
  font-style: italic;
  font-weight: 300;
}

.heading-sub {
  font-family: var(--font-serif);
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.005em;
  color: var(--color-black);
  margin-bottom: 8px;
}

.heading-sub em,
.heading-sub .italic-qualifier {
  font-style: italic;
  font-weight: 400;
}

.heading-card {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 500;
  line-height: 1.2;
}

.heading-card em {
  font-style: italic;
  font-weight: 400;
}

.lede-text {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.55;
  color: var(--color-muted);
  max-width: 56ch;
}

.eyebrow {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.20em;
  color: var(--color-muted);
  margin-bottom: 6px;
  display: block;
}

.panel-title {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--color-muted);
  margin-bottom: 16px;
}

.field-label {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--color-muted);
  display: block;
  margin-bottom: 8px;
}

/* --- 3. Bracketed Tags & Separator Dots --- */
.bracket-tag {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-muted);
  display: inline-block;
  white-space: nowrap;
  transition: color var(--transition-fast);
}

a.bracket-tag:hover,
button.bracket-tag:hover {
  color: var(--color-black);
  text-decoration: underline;
  cursor: pointer;
}

.separator-dot {
  color: var(--color-separator);
  padding: 0 8px;
  font-weight: 300;
}

/* --- 4. Buttons & Controls --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 52px;
  padding: 0 24px;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  border: 1px solid var(--color-black);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  text-decoration: none !important;
}

.btn-primary {
  background-color: var(--color-black);
  color: var(--color-white);
}

.btn-primary:hover {
  background-color: var(--color-white);
  color: var(--color-black);
}

.btn-secondary, .btn-ghost {
  background-color: var(--color-white);
  color: var(--color-black);
}

.btn-secondary:hover, .btn-ghost:hover {
  background-color: var(--color-black);
  color: var(--color-white);
}

.btn:active, .bracket-tag:active {
  transform: scale(0.985);
}

.btn-sm {
  height: 38px;
  padding: 0 16px;
  font-size: 14px;
}

/* --- 5. Icon Badges --- */
.icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background-color: var(--color-black);
  color: var(--color-white);
  flex-shrink: 0;
}

.icon-badge svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* --- 6. Application Layout Shell & Sidebar Navigation --- */
.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--color-white);
  border-right: 1px solid var(--color-hairline);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform var(--transition-fast);
}

.sidebar-header {
  height: var(--header-height);
  padding: 0 24px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--color-hairline);
}

.sidebar-logo-img {
  height: 34px;
  width: auto;
}

.sidebar-logo-fallback {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sidebar-logo-fallback em {
  font-style: italic;
  font-weight: 300;
}

.sidebar-nav {
  flex: 1;
  padding: 24px 0;
  overflow-y: auto;
}

.nav-section-label {
  padding: 0 24px;
  margin-bottom: 8px;
}

.nav-list {
  list-style: none;
  margin-bottom: 28px;
}

.nav-item {
  display: block;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 12px 24px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 400;
  color: var(--color-black);
  border-left: 3px solid transparent;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.nav-link:hover {
  background-color: var(--color-paper);
}

.nav-link.active {
  background-color: var(--color-paper);
  border-left-color: var(--color-black);
  font-weight: 500;
}

.nav-link-badge {
  margin-left: auto;
}

.sidebar-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--color-hairline);
  background-color: var(--color-paper);
}

.user-identity {
  font-size: 12px;
  color: var(--color-muted);
  word-break: break-all;
}

.user-identity strong {
  color: var(--color-black);
  font-weight: 500;
  display: block;
}

/* Main Content Area */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-masthead {
  height: var(--header-height);
  padding: 0 36px;
  border-bottom: 1px solid var(--color-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--color-white);
  position: sticky;
  top: 0;
  z-index: 50;
}

.masthead-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 300;
}

.masthead-title em {
  font-style: italic;
}

.masthead-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mobile-menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--color-black);
  padding: 8px 12px;
  cursor: pointer;
}

.app-content {
  flex: 1;
  padding: 36px;
  max-width: var(--max-width);
  width: 100%;
}

.app-footer {
  padding: 36px;
  border-top: 1px solid var(--color-hairline);
  background-color: var(--color-white);
  margin-top: auto;
}

.footer-inner {
  max-width: var(--max-width);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  font-size: 12px;
  color: var(--color-muted);
}

/* --- 7. Cards, Panels, & Utility Boxes --- */
.card {
  border: 1px solid var(--border-default);
  background-color: var(--surface-default);
  padding: 28px;
  transition: border-color var(--transition-functional), background-color var(--transition-functional);
  display: flex;
  flex-direction: column;
  text-align: left;
}

.card:hover {
  border-color: var(--border-strong);
}

.vendor-card:hover {
  border-color: var(--border-strong);
  background-color: var(--surface-panel);
}

.vendor-card:hover .card-hover-arrow {
  opacity: 1 !important;
  transform: translate(2px, -2px);
}

@keyframes cardEntrance {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.vendor-card {
  animation: cardEntrance 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: left;
}

/* --- Sleek Territory Underline Navigation Bar (No Brackets!) --- */
.terr-nav-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 16px;
  padding-bottom: 0;
}

.terr-tab {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  padding: 6px 0 8px 0;
  position: relative;
  text-decoration: none !important;
  transition: color var(--transition-fast);
  cursor: pointer;
}

.terr-tab:hover {
  color: var(--text-primary);
}

.terr-tab::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background-color: var(--color-black);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.terr-tab.active {
  color: var(--text-primary);
  font-weight: 600;
}

.terr-tab.active::after {
  opacity: 1;
}

/* --- Clean Rectangular Category Tag Grid (0px Border-Radius!) --- */
.cat-pill-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cat-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--text-secondary);
  background-color: var(--surface-default);
  border: 1px solid var(--border-subtle);
  text-decoration: none !important;
  transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  cursor: pointer;
}

.cat-pill:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background-color: var(--surface-panel);
}

.cat-pill.active {
  color: var(--color-white);
  background-color: var(--color-black);
  border-color: var(--color-black);
  font-weight: 600;
}

.card-paper {
  background-color: var(--color-paper);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  text-align: left;
}

.card-footer {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--color-hairline);
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
}

#dir-sort {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 40px !important;
}

.text-link-hover, .footer-link {
  color: var(--color-black);
  text-decoration: none !important;
  font-family: var(--font-sans);
  font-weight: 500;
  transition: color var(--transition-fast);
}

.text-link-hover:hover, .footer-link:hover {
  text-decoration: underline !important;
}

.footer-link-disabled {
  color: var(--color-muted);
  font-family: var(--font-sans);
  font-weight: 400;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap-base);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap-base);
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

/* --- 8. Error Boundary & Alert States (No Red!) --- */
.error-box, .alert-box {
  border: 1px solid var(--color-black);
  background-color: var(--color-paper);
  padding: 32px;
  margin: 24px 0;
}

.error-title {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 500;
  margin-bottom: 12px;
  color: var(--color-black);
  display: flex;
  align-items: center;
  gap: 12px;
}

.error-title em {
  font-style: italic;
  font-weight: 400;
}

.error-body {
  font-size: 14px;
  color: var(--color-muted);
  line-height: 1.6;
}

.error-code {
  font-family: monospace;
  font-size: 12px;
  background-color: var(--color-white);
  border: 1px solid var(--color-hairline);
  padding: 12px;
  margin-top: 16px;
  overflow-x: auto;
}

/* --- 9. Toast Notifications Container --- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.toast {
  background-color: var(--color-black);
  color: var(--color-white);
  padding: 16px 24px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  border: 1px solid var(--color-white);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: toastSlideUp 0.25s ease forwards;
}

.toast.toast-fadeOut {
  animation: toastFadeOut 0.3s ease forwards;
}

@keyframes toastSlideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastFadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* --- 10. Quick-Search Palette, Shortlist Tray & Drafting Panel --- */
.palette-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.palette-backdrop.active {
  display: flex;
  opacity: 1;
}

@keyframes paletteSlideIn {
  from {
    opacity: 0;
    transform: translateY(-16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.palette-box {
  width: 100%;
  max-width: 640px;
  background: var(--color-white);
  border: 2px solid var(--color-black);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.palette-backdrop.active .palette-box {
  animation: paletteSlideIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.palette-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  text-decoration: none;
  color: var(--color-black);
  border-left: 3px solid transparent;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.palette-item:hover,
.palette-item.active {
  background-color: var(--color-paper);
  border-left-color: var(--color-black);
}

.tray {
  position: fixed;
  bottom: 20px;
  right: 20px;
  left: 20px;
  max-width: 900px;
  margin: 0 auto;
  z-index: 900;
  padding: 16px 24px;
  border: 2px solid var(--color-black);
  background: var(--color-white);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  display: none;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

@keyframes traySlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tray.active {
  display: flex;
  animation: traySlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.drafting-panel {
  position: fixed;
  bottom: 80px;
  right: 20px;
  left: 20px;
  max-width: 900px;
  margin: 0 auto;
  z-index: 890;
  padding: 24px;
  border: 2px solid var(--color-black);
  background: var(--color-white);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  display: none;
  flex-direction: column;
  gap: 16px;
  max-height: 60vh;
  overflow-y: auto;
}

.drafting-panel.active {
  display: flex;
  animation: traySlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* --- 11. Mobile Drawer & Responsive Breakpoints --- */
.drawer-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.4);
  z-index: 90;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.drawer-backdrop.active {
  display: block;
  opacity: 1;
}

@media (max-width: 992px) {
  :root {
    --gap-base: 20px;
  }
  
  .grid-3, .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .app-masthead {
    padding: 0 24px;
  }
  
  .app-content {
    padding: 24px;
  }
}

@media (max-width: 768px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  
  .app-sidebar.open {
    transform: translateX(0);
  }
  
  .app-main {
    margin-left: 0;
  }
  
  .mobile-menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
  }
  
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
  
  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }
}

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

/* Print Footer (Hidden in web view, shown only when printing) */
.print-footer {
  display: none;
}

/* Section 10.1 & IA 6.3.16: Client-Safe Print Stylesheet */
@media print {
  body, .app-shell, .app-main, .app-content {
    background-color: #fff !important;
    color: #000 !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }

  /* Hide every sensitive internal block marked with data-internal */
  [data-internal="true"],
  [data-internal],
  .app-sidebar,
  .app-masthead,
  .app-footer,
  .mobile-menu-toggle,
  .tray,
  .palette,
  #guide-calculator,
  #your-cut,
  .btn,
  button {
    display: none !important;
  }

  /* Show clean client-safe print footer */
  .print-footer {
    display: block !important;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid #000;
    font-family: var(--font-sans);
    font-size: 11px;
    color: #000;
    text-transform: uppercase;
    letter-spacing: 0.1em;
  }

  .print-footer strong {
    font-weight: 600;
  }

  /* Ensure no grays lighter than --muted in print per 10.1 */
  .card, .card-paper {
    border: 1px solid #000 !important;
    background: #fff !important;
    box-shadow: none !important;
  }

  a {
    text-decoration: none !important;
    color: #000 !important;
  }

  .heading-display, .heading-sub, .heading-card {
    color: #000 !important;
  }
}
