/*
 * COLLEKTON - Gallery Minimal
 * A razor-sharp CSS foundation for art world interfaces
 * Inspired by Hauser & Wirth, Artlogic, Gagosian, White Cube
 * 
 * Compatible with HTMX + Alpine.js (no JS dependencies)
 */

/* ========================================
   CSS VARIABLES
   ======================================== */

:root {
  /* Base font size - adjust this to scale everything globally */
  --font-size-base: 12px;
  
  /* Typography scale (relative to base) */
  --font-size-xs: 0.65rem;    /* ~7.8px at base 12px */
  --font-size-sm: 0.75rem;     /* ~9px */
  --font-size-base-rel: 0.85rem; /* ~10.2px */
  --font-size-md: 1rem;        /* 12px */
  --font-size-lg: 1.25rem;     /* 15px */
  --font-size-xl: 1.5rem;      /* 18px */
  --font-size-2xl: 2rem;       /* 24px */
  --font-size-3xl: 2.5rem;     /* 30px */
}

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

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: var(--font-size-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.6;
  color: #1a1a1a;
  background: #ffffff;
  min-height: 100vh;
}

/* ========================================
   TYPOGRAPHY
   ======================================== */

h1, h2, h3, h4, h5, h6 {
  font-weight: 400;
  line-height: 1.2;
  margin-bottom: 1rem;
  letter-spacing: 0.02em;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1rem; text-transform: uppercase; letter-spacing: 0.1em; }
h5 { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.1em; color: #666; }
h6 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.15em; color: #999; }

p {
  margin-bottom: 1.5rem;
  max-width: 65ch;
}

small, .small {
  font-size: 0.85rem;
  color: #666;
}

.caps, .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #666;
}

strong, b {
  font-weight: 500;
}

/* ========================================
   LINKS
   ======================================== */

a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}

a:hover {
  border-bottom-color: #1a1a1a;
}

a:active {
  color: #666;
}

/* ========================================
   RULES & DIVIDERS
   ======================================== */

hr {
  border: none;
  border-top: 1px solid #e5e5e5;
  margin: 3rem 0;
}

.rule-light { border-top-color: #f0f0f0; }
.rule-dark { border-top-color: #ccc; }

/* ========================================
   LAYOUT
   ======================================== */

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 3rem 2rem;
}

section {
  margin-bottom: 4rem;
}

section:last-child {
  margin-bottom: 0;
}

header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid #e5e5e5;
}

footer {
  padding: 3rem 2rem;
  border-top: 1px solid #e5e5e5;
  font-size: 0.85rem;
  color: #666;
  max-width: 1400px;
  margin: 0 auto;
}

/* ========================================
   GRID (minimal, semantic)
   ======================================== */

.grid {
  display: grid;
  gap: 2rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
}

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

nav {
  display: flex;
  align-items: center;
  gap: 2rem;
}

nav a {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.25rem 0;
}

nav a:hover {
  border-bottom-color: currentColor;
}

nav a[aria-current="page"],
nav a.active {
  border-bottom-color: #1a1a1a;
}

/* ========================================
   SITE HEADER
   ======================================== */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid #e5e5e5;
  background: #ffffff;
  position: relative;
}

.site-header .header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.site-header .logo {
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: none;
  line-height: 1;
}

/* Mobile nav toggle button - hidden on desktop */
.mobile-nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid #e5e5e5;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.mobile-nav-toggle:hover {
  background: #f5f5f5;
  border-color: #1a1a1a;
}

.mobile-nav-toggle.active {
  background: #1a1a1a;
  color: #fff;
  border-color: #1a1a1a;
}

.mobile-nav-toggle svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

.site-header .logo img {
  height: 20px;
  width: auto;
  display: block;
}

.site-header nav {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  line-height: 1;
}

.site-header nav a {
  display: flex;
  align-items: center;
  line-height: 1;
}

.site-header .auth-section {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  line-height: 1;
}

.site-header .auth-section button,
.site-header .auth-section .auth-user-menu {
  display: flex;
  align-items: center;
  line-height: 1;
}

/* ========================================
   BUTTONS
   ======================================== */

button, .btn, input[type="submit"] {
  display: inline-block;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 0.75rem 1.5rem;
  border: 1px solid #1a1a1a;
  border-radius: 0;
  background: transparent;
  color: #1a1a1a;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

button:hover, .btn:hover, input[type="submit"]:hover {
  background: #1a1a1a;
  color: #ffffff;
}

button:active, .btn:active {
  background: #333;
}

button:disabled, .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button:disabled:hover, .btn:disabled:hover {
  background: #1a1a1a;
  color: #ffffff;
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary, button.primary {
  background: #1a1a1a;
  color: #ffffff;
}

.btn-primary:hover, button.primary:hover {
  background: #333;
}

.btn-ghost, button.ghost {
  border-color: transparent;
  padding: 0.5rem 0.75rem;
}

.btn-ghost:hover, button.ghost:hover {
  background: #f5f5f5;
  color: #1a1a1a;
}

.btn-sm {
  font-size: 0.7rem;
  padding: 0.5rem 1rem;
}

/* ========================================
   FORMS
   ======================================== */

label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #666;
  margin-bottom: 0.5rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="date"],
textarea,
select {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  padding: 0.75rem;
  border: 1px solid #e5e5e5;
  border-radius: 0;
  background: #ffffff;
  color: #1a1a1a;
  transition: border-color 0.15s ease;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #1a1a1a;
}

input::placeholder, textarea::placeholder {
  color: #999;
}

textarea {
  min-height: 8rem;
  resize: vertical;
}

fieldset {
  border: none;
  margin-bottom: 1.5rem;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #1a1a1a;
}

/* ========================================
   TABLES
   ======================================== */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th {
  font-weight: 400;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #666;
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e5e5e5;
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: top;
}

tr:hover td {
  background: #fafafa;
}

/* ========================================
   IMAGES & FIGURES
   ======================================== */

img {
  max-width: 100%;
  height: auto;
  display: block;
}

figure {
  margin-bottom: 2rem;
}

figcaption {
  font-size: 0.75rem;
  color: #666;
  margin-top: 0.75rem;
  letter-spacing: 0.02em;
}

/* ========================================
   CARDS / CONTENT ENTRIES
   ======================================== */

article {
  padding-bottom: 2rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid #f0f0f0;
}

article:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.card {
  display: block;
  border-bottom: none;
}

.card:hover {
  border-bottom: none;
}

.card img {
  margin-bottom: 1rem;
}

.card h3, .card h4, .card h5 {
  margin-bottom: 0.25rem;
}

.card p {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 0.25rem;
}

/* ========================================
   LISTS
   ======================================== */

ul, ol {
  margin-left: 1rem;
  margin-bottom: 1.5rem;
}

li {
  margin-bottom: 0.5rem;
}

ul.plain, ol.plain {
  list-style: none;
  margin-left: 0;
}

dl {
  margin-bottom: 1.5rem;
}

dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #666;
  margin-bottom: 0.25rem;
}

dd {
  margin-bottom: 1rem;
}

/* ========================================
   DROPDOWN MENU
   ======================================== */

.user-menu {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 150px;
  background: #ffffff;
  border: 1px solid #e5e5e5;
  margin-top: 0.5rem;
  z-index: 100;
}

.dropdown-menu a {
  display: block;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  border-bottom: 1px solid #f0f0f0;
}

.dropdown-menu a:last-child {
  border-bottom: none;
}

.dropdown-menu a:hover {
  background: #fafafa;
  border-bottom-color: transparent;
}

/* ========================================
   UTILITIES
   ======================================== */

.muted { color: #999; }
.subtle { color: #666; }
.text-right { text-align: right; }
.text-center { text-align: center; }

.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-2 { margin-bottom: 2rem; }
.mt-3 { margin-top: 3rem; }
.mb-3 { margin-bottom: 3rem; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ========================================
   AUTH VISIBILITY (CSS-based)
   ======================================== */

[x-cloak] {
  display: none !important;
}

/* Default state: not authenticated */
.auth-user-menu { display: none !important; }
.auth-sign-in { display: inline-block !important; }
.auth-show-logged-in { display: none !important; }
.auth-show-logged-out { display: block !important; }
.auth-login-prompt { display: block !important; }

/* Authenticated state */
html.is-authenticated .auth-user-menu { display: block !important; }
html.is-authenticated .auth-sign-in { display: none !important; }
html.is-authenticated .auth-show-logged-in { display: block !important; }
html.is-authenticated .auth-show-logged-out { display: none !important; }
html.is-authenticated .auth-login-prompt { display: none !important; }

/* ========================================
   HTMX LOADING STATES
   ======================================== */

.htmx-request {
  opacity: 0.6;
  pointer-events: none;
}

.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator {
  display: inline-block;
}

/* ========================================
   PRINT
   ======================================== */

@media print {
  body {
    font-size: 10pt;
  }
  
  header, footer, nav, button, .no-print {
    display: none;
  }
  
  main {
    padding: 0;
    max-width: none;
  }
  
  a {
    border-bottom: none;
  }
}

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

/* Mobile Bottom Tab Bar - Hidden on desktop by default */
.mobile-tab-bar {
  display: none;
}

@media (max-width: 768px) {
  /* Font size is controlled by font-size-override.css */
  /* html { font-size: 11px; } - REMOVED to allow CSS variable override */
  
  main {
    padding: 2rem 1rem;
  }
  
  /* Hide regular header nav and auth on mobile */
  .site-header nav {
    display: none;
  }
  
  /* Keep auth section visible in header on mobile, right-aligned */
  .site-header .auth-section {
    display: flex !important;
    margin-left: auto !important;
    order: 999;
  }
  
  /* Show logo centered on mobile */
  .site-header {
    padding: 1rem 1.5rem;
    justify-content: space-between;
    align-items: center;
    position: relative;
  }
  
  .site-header .header-left {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
  }
  
  .site-header .logo {
    align-items: center;
    line-height: 1;
  }
  
  /* Hide hamburger button in header on mobile (it's in tab bar now) */
  .site-header .mobile-nav-toggle {
    display: none !important;
  }
  
  /* Hide nav links on mobile (they're in tab bar) */
  .site-header nav {
    display: none;
  }
  
  /* Mobile Bottom Tab Bar - iOS style - Show on mobile */
  .mobile-tab-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-top: 1px solid #e5e5e5;
    align-items: stretch;
    justify-content: space-around;
    padding: 0.5rem 0;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
    z-index: 1000;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
  }
  
  .mobile-tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.5rem;
    text-decoration: none;
    color: #666;
    transition: color 0.15s ease;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    min-height: 60px;
    font-family: inherit;
  }
  
  .mobile-tab-item:hover,
  .mobile-tab-item:focus {
    color: #1a1a1a;
    text-decoration: none;
    outline: none;
  }
  
  .mobile-tab-item.active {
    color: #1a1a1a;
  }
  
  .mobile-tab-item svg {
    width: 24px;
    height: 24px;
    stroke-width: 1.5;
    flex-shrink: 0;
  }
  
  .mobile-tab-item.active svg {
    stroke-width: 2;
  }
  
  .mobile-tab-label {
    font-size: 0.65rem;
    line-height: 1;
    text-transform: uppercase;
  }
  
  /* Hamburger button in tab bar */
  .mobile-tab-bar .mobile-nav-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.5rem;
    text-decoration: none;
    color: #666;
    transition: color 0.15s ease;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    min-height: 60px;
    font-family: inherit;
  }
  
  .mobile-tab-bar .mobile-nav-toggle:hover,
  .mobile-tab-bar .mobile-nav-toggle:focus {
    color: #1a1a1a;
    outline: none;
  }
  
  .mobile-tab-bar .mobile-nav-toggle.active {
    color: #1a1a1a;
  }
  
  .mobile-tab-bar .mobile-nav-toggle svg {
    width: 24px;
    height: 24px;
    stroke-width: 1.5;
    flex-shrink: 0;
  }
  
  .mobile-tab-bar .mobile-nav-toggle.active svg {
    stroke-width: 2;
  }
  
  /* Add bottom padding to main content to account for tab bar */
  main {
    padding-bottom: calc(2rem + 60px);
  }
  
  /* Ensure pages with full-height layouts account for tab bar */
  .about-app,
  .products-app,
  .network-app {
    padding-bottom: 60px;
  }
  
  hr {
    margin: 2rem 0;
  }
}
