/* ==========================================================================
   GRAPHING CALCULATOR UI STYLES — Calc84 v10.6.4
   Extracted from graphing.html inline block (2026-07-16)
   All px font-sizes converted to rem | All rgba() use CSS variables
   ========================================================================== */

/* ---- 1. GLOBAL RESET & RESPONSIVE FOUNDATION ---- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

img, svg, canvas { max-width: 100%; height: auto; }

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
.skip-link { position: absolute; top: -2.5rem; left: 0; background: var(--ui-highlight); color: var(--txt-func); padding: 0.5rem; text-decoration: none; border-radius: 0 0 0.25rem 0; font-weight: 600; z-index: 10000; }
.skip-link:focus { top: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0; }

/* ---- 2. LOADING STATE ---- */
.graph-loading-overlay { position: absolute; inset: 0; background: var(--screen-bg); display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 30; transition: opacity 0.3s ease; border-radius: inherit; }
.graph-loading-overlay.hidden { opacity: 0; pointer-events: none; }
.skeleton-graph { width: 80%; height: 80%; border-left: 0.125rem solid var(--sidebar-border); border-bottom: 0.125rem solid var(--sidebar-border); position: relative; animation: pulse 1.5s infinite; }
.skeleton-graph::after { content: ''; position: absolute; top: 20%; left: 0; width: 100%; height: 60%; border-top: 0.125rem dashed var(--sidebar-border); border-radius: 50%; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0% { opacity: 0.6; } 50% { opacity: 1; } 100% { opacity: 0.6; } }

/* ---- 3. HEAVY OPERATION LOADING INDICATOR ---- */
.calculation-loading {
    position: fixed; top: 1.25rem; right: 1.25rem;
    background: var(--ui-highlight); color: var(--txt-func);
    padding: 0.625rem 1rem; border-radius: 0.5rem;
    font-weight: 600; font-size: 0.8125rem; z-index: 4000;
    display: flex; align-items: center; gap: 0.5rem;
    box-shadow: 0 0.25rem 0.75rem var(--shadow-color);
    opacity: 0; transform: translateY(-1.25rem);
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
}
.calculation-loading.active { opacity: 1; transform: translateY(0); }
.calculation-loading::before {
    content: '';
    width: 1rem; height: 1rem;
    border: 0.125rem solid rgba(var(--text-primary-rgb), 0.15);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ---- 4. GRAPHING WORKSPACE ---- */
.graphing-workspace { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; width: 100%; max-width: 75rem; margin: 0 auto; background: var(--chassis-bg); color: var(--screen-text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; box-shadow: 0 0 2.5rem var(--shadow-color); }
.graphing-main-area { flex: 1; display: flex; position: relative; flex-direction: column; }
.graph-display-area { flex: 1; position: relative; background: var(--screen-bg); overflow: hidden; isolation: isolate; contain: strict; will-change: transform; border-bottom: 1px solid var(--sidebar-border); min-height: 50vh; aspect-ratio: 16 / 10; max-height: 37.5rem; }
.graph-canvas {
    display: block; width: 100%; height: 100%;
    cursor: crosshair; touch-action: none; outline: none;
    -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.graph-canvas:focus-visible { outline: var(--focus-ring); outline-offset: -0.1875rem; }

/* ---- 5. OVERLAYS ---- */
.graph-overlay { position: absolute; font-family: 'Courier New', monospace; font-weight: 600; z-index: 20; pointer-events: none; transition: opacity 0.15s ease; backdrop-filter: blur(0.25rem); border-radius: 0.375rem; padding: 0.5rem 0.75rem; font-size: 0.75rem; max-width: 18.75rem; word-wrap: break-word; }
.graph-calc-overlay { top: 0.75rem; right: 0.75rem; background: var(--chassis-bg); color: var(--txt-func); border: 1px solid var(--sidebar-border); opacity: 0; }
.graph-calc-overlay.active { opacity: 1; }
.graph-trace-info { bottom: 0.75rem; left: 0.75rem; background: var(--chassis-bg); color: var(--txt-func); border: 1px solid var(--sidebar-border); display: none; }
.graph-trace-info.active { display: block; }
.graph-error-overlay { top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--ui-error); color: var(--txt-func); font-weight: 800; font-size: 0.875rem; display: none; z-index: 1000; text-align: center; padding: 1rem 1.5rem; }
.graph-error-overlay.active { display: block; animation: shake 0.5s ease; }
@keyframes shake { 0%, 100% { transform: translate(-50%, -50%); } 25% { transform: translate(-52%, -50%); } 75% { transform: translate(-48%, -50%); } }
.graphing-mode-indicator { font-size: 0.6875rem; font-weight: 700; color: var(--lbl-primary); text-transform: uppercase; letter-spacing: 0.03125rem; margin-left: auto; padding: 0.25rem 0.5rem; border: 1px solid var(--lbl-primary); border-radius: 0.25rem; background: rgba(var(--lbl-primary-rgb), 0.1); position: absolute; top: 0.625rem; left: 0.625rem; z-index: 10; }

/* ---- 6. GETTING STARTED HINT OVERLAY ---- */
.graph-hint-overlay { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 5; text-align: center; padding: 1.875rem; background: rgba(var(--chassis-bg-rgb, 240, 240, 240), 0.95); border-radius: 1rem; border: 0.125rem dashed var(--sidebar-border); max-width: 25rem; transition: opacity 0.3s ease; }
.graph-hint-overlay.hidden { opacity: 0; pointer-events: none; }
.graph-hint-content { color: var(--sidebar-text-secondary); }
.graph-hint-icon { font-size: 3rem; margin-bottom: 1rem; }
.graph-hint-content h3 { margin: 0 0 0.75rem 0; color: var(--sidebar-text-primary); font-size: 1.125rem; }
.graph-hint-content p { margin: 0; line-height: 1.6; font-size: 0.875rem; }
.graph-hint-content code { background: var(--screen-bg); padding: 0.125rem 0.375rem; border-radius: 0.25rem; font-family: 'Courier New', monospace; color: var(--txt-func); }
[data-theme="dark"] .graph-hint-overlay { background: rgba(var(--chassis-bg-rgb, 30, 30, 30), 0.95); }

/* ---- 7. CONTROLS PANEL ---- */
.graph-controls-panel { flex-shrink: 0; background: var(--ui-dropdown-bg); border-top: 1px solid var(--sidebar-border); height: 40vh; min-height: 15.625rem; max-height: 25rem; overflow-y: auto; box-shadow: 0 -0.3125rem 1.25rem var(--shadow-color); display: flex; flex-direction: column; }
.graph-controls-tabs {
    display: flex; gap: 0.25rem; padding: 0.75rem;
    border-bottom: 1px solid var(--sidebar-border);
    position: sticky; top: 0; background: var(--ui-dropdown-bg);
    z-index: 10; overflow-x: auto;
    -webkit-overflow-scrolling: touch; scroll-behavior: smooth; scrollbar-width: none;
}
.graph-controls-tabs::-webkit-scrollbar { display: none; }
.graph-controls-tab {
    background: none; border: none; color: var(--nav-link-inactive);
    font-weight: 600; padding: 0.5rem 0.75rem; cursor: pointer;
    border-radius: 0.375rem; transition: all 0.15s ease;
    font-size: 0.8125rem; white-space: nowrap; flex: 0 0 auto;
}
.graph-controls-tab:hover { background: rgba(var(--ui-highlight-rgb), 0.1); color: var(--nav-link-active); }
.graph-controls-tab.active { color: var(--txt-func); background: var(--ui-highlight); box-shadow: 0 0.125rem 0 var(--shadow-color); }
.graph-tabs-container { flex: 1; overflow-y: auto; }
.graph-tab-content { display: none; padding: 1rem; }
.graph-tab-content.active { display: block; }

/* ---- 8. Y= EDITOR ---- */
.graph-eq-row {
    display: flex; align-items: center; gap: 0.625rem;
    margin-bottom: 0.625rem; padding: 0.625rem;
    border-radius: 0.5rem; background: var(--chassis-bg);
    transition: background 0.15s ease; position: relative; flex-wrap: wrap;
}
.graph-eq-row:hover { background: var(--ui-dropdown-bg); box-shadow: 0 0.125rem 0.5rem var(--shadow-color); }
.graph-eq-checkbox { width: 1rem; height: 1rem; cursor: pointer; accent-color: var(--ui-highlight); }
.graph-eq-label { font-weight: 700; font-family: 'Courier New', monospace; min-width: 2rem; font-size: 0.875rem; color: var(--sidebar-text-primary); text-align: right; }
.graph-eq-input {
    flex: 1; min-width: 0; padding: 0.625rem 0.75rem;
    border-radius: 0.375rem; border: 0.125rem solid var(--ui-dropdown-border);
    background: var(--ui-dropdown-bg); color: var(--sidebar-text-primary);
    font-family: 'Courier New', monospace; font-size: 0.9375rem; font-weight: 600;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.graph-eq-input:focus { border-color: var(--ui-highlight); box-shadow: 0 0 0 0.1875rem rgba(var(--ui-highlight-rgb), 0.3); outline: none; }
.graph-style-btn { background: var(--ui-dropdown-bg); border: 0.125rem solid var(--ui-dropdown-border); border-radius: 0.25rem; padding: 0.375rem 0.5rem; font-size: 0.6875rem; cursor: pointer; color: var(--sidebar-text-secondary); transition: all 0.15s ease; min-width: 2rem; font-weight: 600; }
.graph-style-btn:hover { border-color: var(--ui-highlight); color: var(--ui-highlight); }
.graph-style-btn.active { background: var(--ui-highlight); color: var(--txt-func); border-color: var(--ui-highlight); }

/* ---- 9. FORM ELEMENTS ---- */
.graph-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); gap: 0.75rem; }
.graph-form-group { display: flex; flex-direction: column; gap: 0.375rem; }
.graph-form-label { font-size: 0.6875rem; font-weight: 700; color: var(--sidebar-text-secondary); text-transform: uppercase; letter-spacing: 0.03125rem; }
.graph-form-input, .graph-form-select { padding: 0.625rem; border-radius: 0.375rem; border: 0.125rem solid var(--ui-dropdown-border); background: var(--ui-dropdown-bg); color: var(--sidebar-text-primary); font-family: 'Courier New', monospace; font-size: 0.875rem; font-weight: 600; }
@media (max-width: 768px) { .graph-form-input, .graph-form-select { font-size: 1rem; } }
.graph-form-input:focus, .graph-form-select:focus { border-color: var(--ui-highlight); outline: none; }

/* ---- 10. BUTTONS ---- */
.graph-btn-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.graph-btn-grid-2 { grid-template-columns: repeat(2, 1fr); }
.graph-btn { background: var(--chassis-bg); border: 0.125rem solid var(--ui-dropdown-border); padding: 0.75rem 0.5rem; border-radius: 0.375rem; color: var(--sidebar-text-primary); font-size: 0.75rem; cursor: pointer; text-align: center; font-weight: 600; transition: all 0.15s ease; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.graph-btn:hover { background: var(--ui-highlight); color: var(--txt-func); border-color: var(--ui-highlight); transform: translateY(-0.0625rem); }
.graph-btn:active { transform: translateY(0.0625rem); }

/* ---- 11. TABLE AREA ---- */
.graph-table-area { flex: 1; background: var(--screen-bg); color: var(--screen-text); font-family: 'Courier New', monospace; overflow: auto; display: none; padding: 0.75rem; font-size: 0.875rem; line-height: 1.4; }
.graph-table-area.active { display: block; }
.graph-table-preview { border-collapse: collapse; width: 100%; background: var(--ui-dropdown-bg); border: 1px solid var(--ui-dropdown-border); border-radius: 0.375rem; overflow: hidden; }
.graph-table-preview th, .graph-table-preview td { border: 1px solid var(--ui-dropdown-border); padding: 0.5rem 0.75rem; text-align: right; font-weight: 600; }
.graph-table-preview th { background: var(--chassis-bg); color: var(--txt-func); position: sticky; top: 0; z-index: 1; }

/* ---- 12. HELP MODAL ---- */
.graph-help-modal { position: fixed; inset: 0; background: var(--ui-modal-bg); backdrop-filter: blur(0.5rem); z-index: 2000; display: none; justify-content: center; align-items: center; padding: 1.25rem; }
.graph-help-modal.active { display: flex; }
.graph-help-content { background: var(--ui-dropdown-bg); border-radius: 1rem; padding: 1.5rem; max-width: 37.5rem; max-height: 80vh; overflow-y: auto; border: 1px solid var(--sidebar-border); box-shadow: 0 1.25rem 3.75rem var(--shadow-color); }
.graph-help-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.graph-help-title { font-size: 1.25rem; font-weight: 700; color: var(--sidebar-text-primary); }
.graph-help-close { background: none; border: none; color: var(--sidebar-text-secondary); font-size: 1.5rem; cursor: pointer; padding: 0.25rem; border-radius: 0.25rem; }
.graph-help-close:hover { background: var(--ui-error); color: var(--txt-func); }
.graph-help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15.625rem, 1fr)); gap: 1.25rem; }
.graph-help-section h3 { font-size: 0.875rem; font-weight: 700; color: var(--sidebar-text-primary); margin-bottom: 0.625rem; text-transform: uppercase; letter-spacing: 0.03125rem; }
.graph-help-item { display: flex; justify-content: space-between; padding: 0.375rem 0; border-bottom: 1px solid var(--ui-dropdown-border); font-size: 0.8125rem; color: var(--sidebar-text-primary); }
.graph-help-key { font-family: 'Courier New', monospace; background: var(--chassis-bg); padding: 0.125rem 0.375rem; border-radius: 0.25rem; font-weight: 600; }

/* ---- 13. LEGAL BANNER ---- */
.legal-banner { background: var(--bg-secondary); border-bottom: 0.125rem solid var(--text-warning); padding: 0.75rem 1.25rem; text-align: center; font-size: 0.9rem; color: var(--text-secondary); }
.legal-banner strong { color: var(--text-primary); }

/* ---- 14. EQUATION LABEL COLOR VARIABLES ---- */
:root {
    --eq-y1-color: #e74c3c;
    --eq-y2-color: #3498db;
    --eq-y3-color: #2ecc71;
    --eq-y4-color: #f1c40f;
    --eq-y5-color: #9b59b6;
    --eq-y6-color: #1abc9c;
}

/* ---- 15. MOBILE RESPONSIVENESS (Max 768px) ---- */
@media (max-width: 768px) {
    .graphing-workspace { width: 100%; max-width: 100%; margin: 0; box-shadow: none; }
    .graph-display-area { min-height: 45vh; max-height: 50vh; }
    .graph-controls-panel { height: auto; flex: 1; min-height: 40vh; }
    .graph-btn-grid { grid-template-columns: repeat(2, 1fr); }
    .graph-form-grid { grid-template-columns: 1fr; }
    .graph-help-grid { grid-template-columns: 1fr; }
    .author-card { flex-direction: column; text-align: center; padding: 1.25rem 0.9375rem; }
    .graph-hint-overlay { padding: 1.25rem; max-width: 90%; }
    .graph-hint-icon { font-size: 2.25rem; }
    .graph-hint-content h3 { font-size: 1rem; }
    .graph-hint-content p { font-size: 0.8125rem; }
    .table-wrapper { margin: 1rem 0; }
}

/* ---- 16. EXTRA SMALL SCREENS (Max 480px) ---- */
@media (max-width: 480px) {
    .graph-controls-tabs { padding: 0.5rem; }
    .graph-controls-tab { padding: 0.375rem 0.5rem; font-size: 0.75rem; }
    .graph-btn-grid { grid-template-columns: 1fr; }
    .graph-eq-label { font-size: 0.75rem; }
    .ai-summary-box { padding: 1rem; }
    .logo-title { font-size: 1.2rem !important; }
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.1rem; }
}


/* ==========================================================================
   THEME-AWARE LINK COLORS (all tool pages)
   ========================================================================== */

/* Light theme fallback (default) */
a {
  color: #0066cc;
}

/* Dark theme – bright readable blue */
[data-theme="dark"] a {
  color: #5dade2;
}

/* Solar theme – gold, matches the solar palette */
[data-theme="solar"] a {
  color: #ffd700;
}

/* Keep navigation links untouched – they already have their own styles */
header a,
.sidebar a,
.nav-link,
.breadcrumb-nav a,
.legal-links a,
.footer a {
  /* inherited or already styled – reset so the above doesn't override them */
  color: inherit;
}

/* Restore footer and legal link colors */
.footer a {
  color: var(--text-secondary);
}
.legal-links a {
  color: var(--link-color); /* or use --accent-secondary if available */
}

/* Hover state */
a:hover {
  text-decoration: underline;
  opacity: 0.9;
}