/* CUEBALL - static/styles.css
Version 1.2.0 */

/* === CSS VARIABLES === */
:root {
  /* Fonts */
  --font-sans: 'Roboto', sans-serif;
  --font-serif: 'Fell', serif;
  --font-mono: 'Roboto Mono', monospace;
  
  /* Colors - Updated for better contrast */
  --color-text: #1a1a1a;
  --color-text-light: #4a4a4a;
  --color-text-muted: #666;
  --color-bg: #faf9f5;
  --color-bg-alt: #fdfdfc;
  --color-bg-white: #fff;
  --color-bg-hover: #f8f9fa;
  --color-accent: #0056b3;
  --color-accent-dark: #004085;
  --color-border: #ccc;
  --color-border-light: #ddd;
  --color-border-dark: #bbb;
  
  /* Success colors */
  --color-success-bg: #d4edda;
  --color-success-border: #c3e6cb;
  --color-success-text: #155724;
  
  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;
  --spacing-xxl: 4rem;
  
  /* Border radius */
  --radius: 6px;
  --radius-lg: 8px;
  
  /* Shadows */
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 6px 16px rgba(0, 0, 0, 0.2);
  --shadow-focus: 0 2px 8px rgba(0, 102, 204, 0.2);
  
  /* Typography */
  --font-size-sm: 0.75rem;
  --font-size-base: 1rem;
  --font-size-md: 1.1rem;
  --font-size-lg: 1.4rem;
  --font-size-xl: 1.6rem;
  --font-size-xxl: 1.8rem;
  --font-size-xxxl: 2.2rem;
  
  /* Line heights */
  --line-height-tight: 1.3;
  --line-height-base: 1.4;
  --line-height-relaxed: 1.5;
  
  /* Breakpoints */
  --bp-sm: 480px;
  --bp-md: 768px;
  
  /* Touch targets */
  --touch-target-min: 44px;
  
  /* Layout */
  --content-width: 600px;
  
  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-medium: 0.3s ease;
}

/* === Custom Font Definition === */
@font-face {
  font-family: 'Fell';
  src: url('/static/fonts/IMFellEnglish-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* === Base Layout === */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-text);
  margin: var(--spacing-md) auto;
  padding: var(--spacing-md);
  line-height: var(--line-height-relaxed);
  width: 100%;
  max-width: var(--content-width);
  /* Improve text rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

@media (min-width: 768px) {
  body {
    margin: var(--spacing-xl) auto;
  }
}

/* === Typography === */
h1 {
  font-size: var(--font-size-xxxl);
  margin-bottom: var(--spacing-xs);
  font-weight: 700;
}

h2 {
  font-size: var(--font-size-xl);
  margin-top: var(--spacing-xl);
  margin-bottom: var(--spacing-sm);
  font-weight: 600;
}

/* Responsive heading sizes */
@media (max-width: 480px) {
  h1 {
    font-size: var(--font-size-xxl);
  }
  
  h2 {
    font-size: var(--font-size-lg);
  }
}

/* Logo styles */
.logo-h1 { 
  text-align: left; 
}

.logo-h1 img { 
  width: 100%; 
  vertical-align: middle; 
}

/* === Links === */
a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover,
a:focus {
  color: var(--color-accent-dark);
  text-decoration: underline;
}

a:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Ensure focus is visible for links too */
a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* === Layout Utilities === */
.full-width {
  width: 100%;
  max-width: var(--content-width);
}

/* === Forms === */
form {
  margin-top: var(--spacing-md);
  margin-bottom: var(--spacing-xl);
}

label {
  display: block;
  margin-top: var(--spacing-md);
  margin-bottom: var(--spacing-xs);
  font-weight: 500;
}

/* Form controls */
select,
button {
  font-family: inherit;
  font-size: var(--font-size-base);
  padding: 0.75rem;
  margin-top: var(--spacing-sm);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background-color: var(--color-bg-white);
  color: var(--color-text);
  box-shadow: var(--shadow);
  touch-action: manipulation;
  transition: all var(--transition-fast);
  min-height: var(--touch-target-min);
}

/* Apply full-width layout to form controls */
select,
button {
  width: 100%;
  max-width: var(--content-width);
}

/* Focus states */
select:focus,
button:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  box-shadow: var(--shadow-focus);
}

/* Ensure focus is visible even in high contrast mode */
select:focus-visible,
button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Button interactions */
button:hover {
  background-color: var(--color-bg-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
  box-shadow: var(--shadow);
}

@media (min-width: 768px) {
  select,
  button {
    min-height: auto;
  }
}

/* === Content Containers === */
.cue-script, 
.character-select {
  position: relative;
  margin: var(--spacing-md) 0;
  overflow-x: auto;
  background-color: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--spacing-xs);
}

@media (min-width: 768px) {
  .cue-script,
  .character-select {
    margin: var(--spacing-md) auto;
  }
}

/* Script text styling */
.cue-script pre {
  font-family: var(--font-serif);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  margin: 0;
}

#cue-script-text {
  font-family: var(--font-serif);
  font-feature-settings:
    "liga" 1,
    "hlig" 1,
    "dlig" 1,
    "hist" 1,
    "kern" 1,
    "ss06" 1;
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
}

@media (min-width: 768px) {
  .cue-script pre,
  #cue-script-text {
    font-size: var(--font-size-md);
  }
}

/* === Copy Button === */
.copy-button {
  position: fixed;
  bottom: var(--spacing-md);
  right: var(--spacing-md);
  width: 80px;
  background-color: var(--color-bg-white);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: 0.75rem var(--spacing-sm);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-light);
  cursor: pointer;
  z-index: 1000;
  transition: all var(--transition-fast);
  user-select: none;
  touch-action: manipulation;
  box-shadow: var(--shadow-lg);
  min-height: var(--touch-target-min);
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (min-width: 768px) {
  .copy-button {
    top: var(--spacing-md);
    bottom: auto;
    min-height: auto;
    width: 75px;
    padding: var(--spacing-sm);
  }
}

.copy-button:hover {
  background-color: var(--color-bg-hover);
  border-color: var(--color-border-dark);
  color: var(--color-text);
  box-shadow: var(--shadow-xl);
  transform: translateY(-2px);
}

.copy-button:active {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.copy-button.copied {
  background-color: var(--color-success-bg);
  border-color: var(--color-success-border);
  color: var(--color-success-text);
}

/* === Code Blocks === */
pre {
  background-color: var(--color-bg-alt);
  padding: 1em;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  white-space: pre-wrap;
  overflow-x: auto;
}

@media (min-width: 768px) {
  pre {
    font-size: 0.95rem;
  }
}

/* === Footer === */
footer {
  margin-top: var(--spacing-xxl);
  color: var(--color-text-muted);
  font-size: .85rem;
  text-align: left;
}

footer a {
  color: var(--color-text-muted);
  text-decoration: underline;
}
footer a:hover {
  color: var(--color-text-light); /* barely changes */
}

/* === Accessibility === */
.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;
}

/* Reduced motion preference */
@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;
    transform: none !important;
  }
  
  /* Keep essential focus indicators */
  select:focus,
  button:focus,
  a:focus,
  select:focus-visible,
  button:focus-visible,
  a:focus-visible {
    transition: none !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --color-text: #000;
    --color-text-light: #000;
    --color-text-muted: #000;
    --color-bg: #fff;
    --color-bg-alt: #fff;
    --color-bg-white: #fff;
    --color-border: #000;
    --color-border-light: #000;
    --color-border-dark: #000;
    --color-accent: #0000ff;
    --color-accent-dark: #0000cc;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.5);
  }
}

/* === Print Styles === */
@media print {
  .copy-button {
    display: none;
  }
  
  body {
    width: 100%;
    margin: 0;
    padding: var(--spacing-md);
    background: white;
    color: black;
  }
  
  .cue-script {
    box-shadow: none;
    border: 1px solid var(--color-border);
  }
  
  /* Ensure good page breaks */
  h1, h2 {
    page-break-after: avoid;
  }
  
  .cue-script {
    page-break-inside: avoid;
  }
}
