/* =============================================================================
   RESET & BASE STYLES
   ============================================================================= */

/* Universal reset for consistent box model and default removal */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Image defaults */
img {
  display: block;
  max-width: 100%;
}

/* Link and button base styles */
a {
  color: inherit;
  text-decoration: none;
}

/* Button styling for interactive elements */
button {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  background: transparent;
  border: 1.5px solid var(--ink);
  border-radius: 3px;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, transform 0.1s;
}

button:hover {
  background: var(--ink);
  color: var(--bg);
}

button:active {
  transform: scale(0.97);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 21, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 200;
}

.dialog-panel {
  width: min(480px, 100%);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(28, 25, 21, 0.14);
  overflow: hidden;
  font-family: var(--font-mono);
}

.dialog-panel__body {
  padding: 1.5rem;
}

.dialog-panel h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--ink);
  line-height: 1.3;
}

.dialog-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 1rem;
}

.dialog-field label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
}

.dialog-input,
.dialog-textarea {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.85rem 1rem;
  transition: border-color 0.15s, background 0.15s;
}

.dialog-input:focus,
.dialog-textarea:focus {
  outline: none;
  border-color: var(--ink);
}

.dialog-textarea {
  min-height: 120px;
  resize: vertical;
}

.dialog-status {
  margin: 1rem 0 0;
  min-height: 1.25rem;
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.sidebar-footer-actions {
  margin-top: 1rem;
}

button.primary:hover {
  background: #a03318;
  border-color: #a03318;
}

/* =============================================================================
   DESIGN TOKENS
   ============================================================================= */

/* CSS custom properties for colors, fonts, and dimensions */
:root {
  --bg: #f5f2ec;           /* Main background color */
  --ink: #1c1915;          /* Primary text color */
  --ink-muted: #8a8278;    /* Muted text color */
  --accent: #c84b2f;       /* Accent color for highlights */
  --rule: #d8d3ca;         /* Border and divider color */
  --sidebar-w: 300px;      /* Sidebar width */
  --font-serif: 'EB Garamond', serif;  /* Serif font stack */
  --font-mono: 'Courier Prime', monospace;            /* Monospace font stack */
}

/* =============================================================================
   LAYOUT & STRUCTURE
   ============================================================================= */

/* HTML and body setup for smooth scrolling and grid layout */
html {
  scroll-behavior: smooth;
  background: var(--bg);
  color: var(--ink);
}

body {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* =============================================================================
   SIDEBAR NAVIGATION
   ============================================================================= */

/* Sticky sidebar with navigation */
#sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  padding: 3rem 2rem 2rem;
  background: var(--bg);
  z-index: 10;
}

/* Hide scrollbar for cleaner look */
#sidebar::-webkit-scrollbar {
  width: 0;
}

/* Sidebar header with title and tagline */
.sidebar-header {
  margin-bottom: 3rem;
}

.sidebar-header h1 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.01em;
  line-height: 1.2;
  color: var(--ink);
}

.sidebar-header .tagline {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 300;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-top: 0.5rem;
}

/* Navigation divider line */
.nav-divider {
  width: 24px;
  height: 1px;
  background: var(--rule);
  margin-bottom: 2rem;
}

/* Category labels in navigation */
.nav-category {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 0.6rem;
  margin-top: 1.6rem;
}

.nav-category:first-of-type {
  margin-top: 0;
}

/* Navigation list styling */
#sidebar nav ul {
  list-style: none;
}

#sidebar nav ul li + li {
  margin-top: 0.15rem;
}

/* Navigation links with hover and active states */
#sidebar nav a {
  font-family: 'Courier New', Courier, monospace;
  font-size: 1rem;
  display: block;
  padding: 0.25rem 0 0.25rem 1rem;
  border-left: 1.5px solid transparent;
  color: var(--ink-muted);
  transition: color 0.2s, border-color 0.2s;
  line-height: 1.4;
}

#sidebar nav a:hover {
  color: var(--ink);
}

#sidebar nav a.active {
  color: var(--ink);
  border-left-color: var(--accent);
}

/* Sidebar footer with contact info */
.sidebar-footer {
  margin-top: auto;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
}

.sidebar-footer p {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 300;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  line-height: 1.8;
}

.sidebar-footer a:hover {
  color: var(--accent);
}

/* =============================================================================
   FORM CONTROLS
   ============================================================================= */

/* Control sections for grouping form fields */
.control-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.section-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
}

/* Form field container */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--ink-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Text and number inputs, selects */
input[type="text"],
input[type="number"],
select {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.5rem 0.65rem;
  width: 100%;
  appearance: none;
  transition: border-color 0.15s, background 0.15s;
  outline: none;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  border-color: var(--ink);
  background: #ffffff;
}

/* Custom select dropdown styling */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%231c1915'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
  cursor: pointer;
}

/* Field row for side-by-side fields */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

/* Error message styling */
.error {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  background: #fdf0ed;
  border: 1px solid #f5c4b9;
  border-radius: 3px;
  padding: 0.5rem 0.75rem;
  display: none;
}

.error.visible {
  display: block;
}

/* =============================================================================
   MOBILE NAVIGATION
   ============================================================================= */

/* Hamburger menu button (hidden on desktop) */
#menu-toggle {
  display: none;
  position: fixed;
  top: 1.2rem;
  left: 1.2rem;
  z-index: 200;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--rule);
}

#menu-toggle span {
  display: block;
  width: 18px;
  height: 1px;
  background: var(--ink);
  position: relative;
  transition: background 0.2s;
}

#menu-toggle span::before,
#menu-toggle span::after {
  content: '';
  position: absolute;
  left: 0;
  width: 18px;
  height: 1px;
  background: var(--ink);
  transition: transform 0.25s;
}

#menu-toggle span::before {
  top: -5px;
}

#menu-toggle span::after {
  top: 5px;
}

/* Animated hamburger to X when menu is open */
body.menu-open #menu-toggle span {
  background: transparent;
}

body.menu-open #menu-toggle span::before {
  transform: rotate(45deg) translate(3.5px, 3.5px);
}

body.menu-open #menu-toggle span::after {
  transform: rotate(-45deg) translate(3.5px, -3.5px);
}

/* Overlay for mobile menu */
#overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  z-index: 99;
}

body.menu-open #overlay {
  display: block;
}

/* =============================================================================
   MAIN CONTENT AREA
   ============================================================================= */

/* Scrollable main content */
#content {
  overflow-y: auto;
  height: 100vh;
}

/* =============================================================================
   UTILITY PANELS & LAYOUTS
   ============================================================================= */

/* Preview panel for displaying generated content */
.preview {
  padding: 2.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  background: transparent;
}

.preview-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* Display stage for barcode and other content */
.stage {
  background: #ffffff;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  position: relative;
  transition: box-shadow 0.2s;
}

.stage::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 4px;
  border: 3px solid transparent;
  pointer-events: none;
  transition: border-color 0.2s;
}

.stage.updated::before {
  border-color: var(--accent);
  animation: pulse-border 0.4s ease forwards;
}

@keyframes pulse-border {
  0% {
    border-color: var(--accent);
    opacity: 1;
  }
  100% {
    border-color: transparent;
    opacity: 0;
  }
}

#barcode {
  display: block;
}

.hrt-text {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink);
  letter-spacing: 0.12em;
  margin-top: 0.5rem;
}

/* Metrics grid for displaying parameters */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 0.6rem;
}

.metric-card {
  background: #ffffff;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.75rem 1rem;
}

.metric-card-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  display: block;
  margin-bottom: 0.25rem;
}

.metric-card-val {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
}

.metric-card.highlight {
  background: var(--ink);
  border-color: var(--ink);
}

.metric-card.highlight .metric-card-label {
  color: #666;
}

.metric-card.highlight .metric-card-val {
  color: var(--bg);
}

/* Compliance and informational notes */
.compliance-note {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ink-muted);
  border-left: 3px solid var(--rule);
  padding-left: 0.75rem;
  line-height: 1.7;
}

.compliance-note strong {
  color: #555;
  font-weight: 500;
}

/* Action button group */
.actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* =============================================================================
   PROJECT SECTIONS & BLOCKS
   ============================================================================= */

/* Project section with fade-in animation */
.project-section {
  padding: 5rem 4rem 0;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.project-section.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Project header with number, title, and meta */
.project-header {
  padding-bottom: 3rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 0;
}

.project-header .number {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 300;
  letter-spacing: 0.14em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.project-header h2 {
  font-family: var(--font-serif);
  font-size: 3.2rem;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.project-header .meta {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 300;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  margin-top: 1.25rem;
  text-transform: uppercase;
}

/* Content blocks with image and text */
.block {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: start;
  min-height: 100vh;
  padding: 4rem 0;
  border-bottom: 1px solid var(--rule);
}

.block:last-of-type {
  border-bottom: none;
}

/* Block image container */
.block__image {
  position: sticky;
  top: 2rem;
  align-self: start;
}

.block__image .img-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4/3;
  background: var(--rule);
}

.block__image .img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease;
}

.block__image .img-wrap:hover img {
  transform: scale(1.03);
}

.block__image figcaption {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 300;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin-top: 0.75rem;
  text-transform: uppercase;
}

/* Block text content */
.block__text {
  padding-top: 0.5rem;
}

.block__text h3 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 400;
  font-style: italic;
  margin-bottom: 1.25rem;
  line-height: 1.2;
}

.block__text p {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--ink);
  margin-bottom: 1.2rem;
}

.block__text p:last-child {
  margin-bottom: 0;
}

/* Tag list for project tags */
.block__text .tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 2rem;
}

.tag-list span {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 300;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  border: 1px solid var(--rule);
  padding: 0.3rem 0.6rem;
}

/* =============================================================================
   HERO SECTION
   ============================================================================= */

/* Hero intro with animation */
#hero {
  padding: 5rem 4rem 3rem;
  border-bottom: 1px solid var(--rule);
  opacity: 0;
  animation: fadeUp 0.8s 0.2s forwards ease;
  transform: translateY(20px);
}

@keyframes fadeUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#hero .kicker {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 300;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 1.5rem;
}

#hero h2 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 4vw, 3.5rem);
  font-weight: 400;
  line-height: 1.15;
  max-width: 680px;
}

#hero h2 em {
  font-style: italic;
  color: var(--accent);
}

/* =============================================================================
   UTILITY CLASSES
   ============================================================================= */

/* Placeholder images (SVG fallbacks) */
.placeholder-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Section spacing */
.section-end-pad {
  height: 6rem;
}

/* Horizontal rule */
hr {
  border: none;
  border-top: 1px solid var(--rule);
}

/* =============================================================================
   RESPONSIVE DESIGN
   ============================================================================= */

/* Tablet and mobile adjustments */
@media (max-width: 768px) {
  body {
    grid-template-columns: 1fr;
  }

  #sidebar {
    position: fixed;
    left: -100%;
    transition: left 0.3s ease;
    width: 80%;
    max-width: 300px;
    height: 100vh;
    z-index: 100;
    border-right: 1px solid var(--rule);
    padding: 4rem 2rem 2rem;
  }

  body.menu-open #sidebar {
    left: 0;
  }

  #menu-toggle {
    display: flex;
  }

  #content {
    height: auto;
    overflow-y: visible;
  }

  html {
    overflow-y: auto;
  }

  #hero,
  .project-section {
    padding: 4rem 1.5rem 0;
  }

  .block {
    grid-template-columns: 1fr;
    gap: 2rem;
    padding: 3rem 0;
    min-height: auto;
  }

  .block__image {
    position: relative;
    top: auto;
  }

  .project-header h2 {
    font-size: 2.2rem;
  }

  /* Barcode/utility panel adjustments */
  .preview {
    padding: 2rem 1.5rem;
  }
}
