/* Shared styles for all PF pages */
body { font-family: monospace; margin: 0 auto; padding: 0 1.5rem 2rem; background: #fff; }
h1 { margin-bottom: 0.5rem; }
h2 { margin-top: 1.5rem; margin-bottom: 0.5rem; border-bottom: 1px solid #ccc; padding-bottom: 0.25rem; }
button { font-family: monospace; padding: 3px 10px; cursor: pointer; }
a { color: #2255aa; }

/* Import-running warning banner */
.import-warning-banner {
  background: #fff3cd; border: 1px solid #ffc107;
  border-radius: 4px; padding: 0.4rem 0.8rem;
  margin-bottom: 0.75rem; font-size: 0.9em; color: #856404;
}

/* Auth nudge banner (reuses .import-warning-banner colouring) */
#auth-nudge { margin-bottom: 0.75rem; }

/* Navigation */
.site-nav {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  padding: 0.6rem 0;
  margin-bottom: 1rem;
  border-bottom: 2px solid #ccc;
  font-size: 0.95rem;
}
.site-nav a { text-decoration: none; color: #333; }
.site-nav .nav-share { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.share-btn { padding: 3px 12px; cursor: pointer; }
.share-status { font-size: 0.8rem; color: #2e7d32; }
.site-nav a:hover { color: #2255aa; }
.site-nav a.nav-home { font-weight: bold; font-size: 1.1rem; margin-right: 0.5rem; color: #111; }
/* Menu button and in-menu sign-in: phones only (see the mobile section). */
.nav-toggle, .site-nav .nav-auth-menu { display: none; }

.site-nav a.active,
.site-nav .nav-dropdown-trigger.active {
    color: #2255aa;
    font-weight: 600;
    background: #eaf0fb;
    padding: 0.15rem 0.55rem;
    border-radius: 3px;
    border-bottom: 2px solid #2255aa;
    margin-bottom: -2px;
}

/* Nav dropdown (Boats / Designs) */
.nav-dropdown {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.nav-dropdown-trigger {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: #333;
    cursor: pointer;
}

.nav-dropdown-trigger:hover {
    color: #2255aa;
}

.nav-caret {
    font-size: 0.75em;
    margin-left: 0.15rem;
    opacity: 0.7;
}

/* Invisible hover bridge below the trigger so the cursor can travel down to the
   menu without ever leaving .nav-dropdown's :hover zone. */
.nav-dropdown::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 0.5rem;
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 8rem;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    z-index: 50;
    padding: 0.25rem 0;
}

.nav-dropdown-menu a {
    display: block;
    padding: 0.4rem 0.9rem;
    text-decoration: none;
    color: #333;
}

.nav-dropdown-menu a:hover {
    background: #eaf0fb;
    color: #2255aa;
}

.nav-dropdown.open .nav-dropdown-menu {
    display: block;
}

@media (hover: hover) and (pointer: fine) {
    .nav-dropdown:hover .nav-dropdown-menu {
        display: block;
    }
}

/* Landing page */
.landing { max-width: 800px; }
.landing h1 { margin-top: 1.5rem; font-size: 2rem; }
.lead { font-size: 1.1rem; margin-bottom: 0.5rem; }
.landing p { line-height: 1.6; margin-bottom: 0.75rem; }
.landing-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; margin-top: 2rem; }
.landing-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border: 1px solid #ccc;
  padding: 1rem;
  text-decoration: none;
  color: #111;
  background: #fafafa;
}
.landing-card:hover { background: #f0f4ff; border-color: #2255aa; }
.landing-card strong { font-size: 1.05rem; }
.landing-card span { font-size: 0.85rem; color: #555; line-height: 1.4; }

/* What's New section */
.release-notes-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #ccc;
}

.release-notes-section h2 {
    margin-top: 0;
}

.release-notes-box {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f9f9f9;
    padding: 1rem;
}

.release-notes-box h3 {
    margin-top: 0.75rem;
    margin-bottom: 0.3rem;
    font-size: 0.95rem;
}

.release-notes-box h3:first-child {
    margin-top: 0;
}

.release-notes-box p {
    margin: 0.3rem 0;
    line-height: 1.4;
}

.release-notes-box ul {
    margin: 0.3rem 0;
    padding-left: 1.5rem;
}

.release-notes-box li {
    margin: 0.15rem 0;
    line-height: 1.4;
}

/* Stats */
.stats { display: flex; gap: 3rem; background: #f5f5f5; padding: 1rem; margin-bottom: 0.5rem; }
.stat strong { display: block; font-size: 2rem; }
.stat-excluded { display: block; font-size: 0.7rem; color: #999; line-height: 1; margin-top: -0.2rem; }

/* Importers table — order column */
.order-col { white-space: nowrap; padding: 2px 2px; }
.order-btn { padding: 0 4px; font-size: 0.85rem; line-height: 1.4; }

/* Importers table */
.badge { padding: 2px 8px; border-radius: 3px; font-size: 0.75rem; }
.badge-idle { background: #eee; color: #555; }
.badge-running { background: #4caf50; color: #fff; }
.importer-table { width: auto; }
.importer-table th, .importer-table td { padding-left: 0.75rem; padding-right: 0.75rem; }
.importer-table td:nth-child(3) { white-space: nowrap; }
tr.excluded td { color: #aaa; }

tr.excluded .link-btn {
    color: #aaa;
}

tr.excluded .link-btn:hover {
    color: #888;
}
.excluded-inline { color: #aaa; }
.link-btn.excluded-link { color: #7a8fb0; }
.link-btn.excluded-link:hover { color: #5a6f90; }
td.excluded-link { color: #7a8fb0; }
tr.ignored td { font-style: italic; }
.link-btn.ignored-link { font-style: italic; }
td.ignored-link { font-style: italic; }

/* Schedule section */
.schedule-days { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.schedule-days label { display: flex; align-items: center; gap: 0.3rem; font-size: 0.9rem; }
#schedule-time { font-family: monospace; padding: 2px 4px; }

/* Data browser tabs */
.tabs { display: flex; }
.tab { padding: 0.4rem 1rem; cursor: pointer; border: 1px solid #ccc; background: #eee; border-bottom: none; }
.tab:first-child { border-radius: 4px 0 0 0; }
.tab:last-child { border-radius: 0 4px 0 0; }
.tab.active { background: #fff; border-bottom: 1px solid #fff; margin-bottom: -1px; z-index: 1; position: relative; }
.tab-panel { border: 1px solid #ccc; padding: 1rem; display: none; }
.tab-panel.active { display: block; }
.search-row { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.75rem; }
.search-row input[type="text"] { font-family: monospace; padding: 4px; width: 300px; max-width: 600px; flex: 1 1 300px; }
.search-clear-btn { padding: 2px 6px; font-size: 0.8rem; line-height: 1; background: none; border: 1px solid #ccc; border-radius: 3px; cursor: pointer; color: #666; margin-left: -0.25rem; }
.search-clear-btn:hover { background: #f0f0f0; color: #333; }
.search-row label { display: flex; align-items: center; gap: 0.3rem; white-space: nowrap; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; padding: 4px 8px; background: #f0f0f0; border-bottom: 2px solid #ccc; position: sticky; top: 0; z-index: 1; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { background: #e0e0e0; }
th.sort-active { color: #2255aa; }
td { padding: 4px 8px; border-bottom: 1px solid #eee; }
td.id-col { max-width: 20em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Date columns - ensure minimum width for YYYY-MM-DD format */
td.date-col, th.date-col {
    min-width: 11ch;
    white-space: nowrap;
}

tr:hover td { background: #f9f9f9; cursor: pointer; }
tr.selected td { background: #e8f0fe; }
.pagination { margin-top: 0.5rem; display: flex; gap: 0.5rem; align-items: center; font-size: 0.85rem; }
.table-scroll { overflow-x: auto; }
.scroll-status { font-size: 0.8rem; color: #888; padding: 0.3rem 0; }
pre { background: #f5f5f5; padding: 1rem; overflow: auto; max-height: 400px; font-size: 0.8rem; margin-top: 0.75rem; white-space: pre-wrap; word-break: break-all; }
.detail-panel { display: none; }
.detail-panel.visible { display: block; }

/* Collapsible JSON tree */
.json-tree { font-family: monospace; font-size: 1.2em; line-height: 1.6; }
.json-tree details { margin-left: 1.1em; }
.json-tree summary.jt-sum {
  cursor: pointer; list-style: none; display: inline;
  color: #555; user-select: none;
}
.json-tree summary.jt-sum::before { content: '▶ '; font-size: 0.75em; color: #999; }
.json-tree details[open] > summary.jt-sum::before { content: '▼ '; }
.json-tree .jt-body { border-left: 1px solid #e0e0e0; margin-left: 0.3em; padding-left: 0.5em; }
.json-tree .jt-row { padding: 1px 0; }
.json-tree .jt-key  { color: #881391; }
.json-tree .jt-str  { color: #1a6b25; }
.json-tree .jt-num  { color: #1c5cb7; }
.json-tree .jt-bool { color: #c47900; }
.json-tree .jt-null { color: #999; font-style: italic; }
.json-tree .jt-punct { color: #555; }

/* Raw JSON disclosure */
.raw-json-outer {
    margin-top: 0.75rem;
    border-top: 1px solid #e8e8e8;
    padding-top: 0.5rem;
}

.raw-json-outer > summary {
    cursor: pointer;
    font-size: 0.8rem;
    color: #aaa;
    user-select: none;
    list-style: none;
}

.raw-json-outer > summary::before {
    content: '▶ ';
    font-size: 0.75em;
}

.raw-json-outer[open] > summary::before {
    content: '▼ ';
}

.raw-json-outer > summary:hover {
    color: #555;
}

/* Analysis */
.analysis-controls { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.analysis-controls select, .analysis-controls input[type=number] { font-family: monospace; padding: 3px 6px; }
.analysis-controls label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; }
#analysis-plot { width: 100%; height: 420px; }
.conv-table { max-height: 400px; overflow-y: auto; }
.conv-table table { width: auto; min-width: 360px; }
.weight-bar { display: inline-block; background: #4caf50; height: 10px; vertical-align: middle; }

/* Data browser filter banner */
.filter-banner {
    background: #e8f0fe; border: 1px solid #aac4f7;
    border-radius: 4px; padding: 0.3rem 0.7rem;
    margin-bottom: 0.5rem; font-size: 0.9em;
}
.filter-banner button { margin-left: 0.7rem; cursor: pointer; }

/* Inline action link button (Finishes, Boats) */
.link-btn { background: none; border: none; color: #2255aa; cursor: pointer; padding: 0; font-family: monospace; font-size: inherit; text-decoration: underline; }

/* Comparison page */
.comparison-controls { margin-bottom: 1rem; }
.selector-panels { display: flex; gap: 1.5rem; margin-bottom: 0.75rem; }
.selector-panel { display: flex; flex-direction: column; gap: 0.4rem; flex: 1; min-width: 0; }
.selector-panel h3 { margin: 0 0 0.25rem; font-size: 1rem; }
.selector-search { font-family: monospace; padding: 4px 6px; width: 100%; box-sizing: border-box; }
.selector-list {
    border: 1px solid #ccc; height: 200px; overflow-y: auto;
    background: #fafafa; font-size: 0.88rem;
}
.selector-item { padding: 4px 8px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.selector-item:hover { background: #f0f4ff; }
.selector-item.focused { background: #e8f0fe; font-weight: bold; }
.selector-empty { padding: 4px 8px; color: #999; font-style: italic; }
.all-available-label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; }
.comparison-options-row { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.variant-label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; }
.variant-label select { font-family: monospace; padding: 3px 6px; }

/* Comparison chips */
.chip-list { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem; min-height: 1.5rem; }
.chip {
    display: inline-flex; align-items: center; gap: 0.3rem;
    border: 2px solid; border-radius: 14px;
    padding: 2px 8px 2px 10px; font-size: 0.85rem;
    background: #fff; white-space: nowrap;
}
.chip-close {
    background: none; border: none; cursor: pointer;
    font-size: 1rem; line-height: 1; padding: 0; color: inherit;
    opacity: 0.6; margin-left: 2px; font-family: monospace;
}
.chip-close:hover { opacity: 1; }
.chip-clear-all {
    align-self: center; background: none; border: 1px solid #aaa;
    border-radius: 12px; cursor: pointer; font-size: 0.8rem;
    color: #666; padding: 2px 10px; line-height: 1.4;
}
.chip-clear-all:hover { background: #f0f0f0; color: #c00; border-color: #c00; }

/* Division navigation */
.division-nav { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.5rem; }
.division-nav h2 { margin: 0; flex: 1; font-size: 1.1rem; text-align: center; }
.division-nav button { white-space: nowrap; }

/* PF calculator */
.pf-calc-table { width: auto; border-collapse: collapse; }
.pf-calc-table td { padding: 3px 8px; vertical-align: middle; }

/* Info button (ⓘ) — tooltip on hover, links to docs on click */
.info-btn {
    position: relative;
    display: inline-block;
    color: #2255aa;
    text-decoration: none;
    font-size: 0.78em;
    cursor: help;
    margin-left: 0.25em;
    vertical-align: middle;
    line-height: 1;
}
.info-btn::after {
    content: attr(data-tip);
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: #222;
    color: #fff;
    padding: 5px 9px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: sans-serif;
    font-weight: normal;
    white-space: normal;
    width: 240px;
    text-align: left;
    z-index: 1000;
    display: none;
    pointer-events: none;
    line-height: 1.4;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.info-btn:hover::after {
    display: block;
}
/* Longer, multi-line tips: line breaks (&#10;) in data-tip are kept. */
.info-btn-wide::after {
    width: 380px;
    white-space: pre-line;
}

/* --- Mobile responsive --- */
@media (max-width: 768px) {
    body { padding: 0 0.5rem 1rem; }

    /* A top bar (home, Share, ☰); ☰ opens the pages as a full-width list of rows. */
    .site-nav {
        flex-wrap: wrap;
        gap: 0;
        font-size: 1rem;
        padding: 0.3rem 0;
    }
    .site-nav > span:first-child { margin-right: auto; }
    .site-nav a.nav-home { margin-right: 0; }
    .site-nav .nav-share { order: 1; margin-left: 0; }
    .site-nav .nav-share .nav-auth { display: none; }   /* in the menu instead */
    .nav-toggle {
        display: block;
        order: 2;
        margin-left: 0.5rem;
        font-size: 1.4rem;
        line-height: 1;
        padding: 0.25rem 0.6rem;
        background: none;
        border: 1px solid #ccc;
        border-radius: 4px;
        cursor: pointer;
    }
    .site-nav .info-btn { display: none; }

    .site-nav > span:not(:first-child):not(.nav-share),
    .site-nav > .nav-auth-menu { display: none; order: 3; width: 100%; }
    .site-nav.open > span:not(:first-child):not(.nav-share),
    .site-nav.open > .nav-auth-menu { display: block; border-top: 1px solid #eee; }
    .site-nav.open > span:not(:first-child) > a:not(.info-btn),
    .site-nav.open .nav-dropdown-menu a,
    .site-nav.open > .nav-auth-menu {
        display: block;
        padding: 0.7rem 0.5rem;
    }
    .site-nav.open > .nav-auth-menu { font-size: 0.9rem; color: #555; }
    .site-nav.open > .nav-auth-menu a { display: inline; padding: 0; }
    .site-nav.open a.active {
        border-bottom: none;
        margin-bottom: 0;
        border-radius: 0;
        border-left: 3px solid #2255aa;
    }

    /* Boats / Designs: a heading with their pages under it */
    .nav-dropdown { display: block; }
    .nav-dropdown::after { display: none; }
    .site-nav .nav-dropdown-trigger,
    .site-nav .nav-dropdown-trigger.active {
        pointer-events: none;
        padding: 0.6rem 0.5rem 0.1rem;
        font-size: 0.8rem;
        color: #777;
        font-weight: normal;
        background: none;
        border: none;
        margin: 0;
    }
    .nav-caret { display: none; }
    .nav-dropdown-menu,
    .nav-dropdown.open .nav-dropdown-menu {
        display: block;
        position: static;
        background: none;
        border: none;
        box-shadow: none;
        padding: 0;
        margin: 0;
        min-width: 0;
    }
    .site-nav.open .nav-dropdown-menu a { padding-left: 1.5rem; }

    h1 { font-size: 1.3rem; }

    .tabs { flex-wrap: wrap; }
    .tab {
        flex: 1 1 auto;
        text-align: center;
        padding: 0.3rem 0.5rem;
        font-size: 0.8rem;
        border-radius: 0;
    }
    .tab:first-child { border-radius: 4px 0 0 0; }
    .tab:last-child { border-radius: 0 4px 0 0; }

    .search-row {
        flex-wrap: wrap;
    }
    .search-row input[type="text"] {
        flex: 1 1 100%;
        max-width: none;
        width: 100%;
    }
    .search-row label { font-size: 0.8rem; margin-left: 0 !important; }

    .table-scroll { -webkit-overflow-scrolling: touch; }
    table { font-size: 0.8rem; }
    th, td { padding: 3px 5px; }
    td.id-col { max-width: 15em; }

    .detail-panel { font-size: 0.85rem; }
    .json-tree { font-size: 1em; }

    .selector-panels { flex-direction: column; }

    .chart-tall  { height: 500px !important; }
    .chart-med   { height: 400px !important; }

    .stats { flex-wrap: wrap; gap: 1rem; justify-content: center; }
    .stat strong { font-size: 1.5rem; }

    .landing { padding: 0; }
    .landing h1 { font-size: 1.4rem; }

    .comparison-options-row { gap: 0.5rem 1rem; }

    .conv-table table { min-width: auto; }

    .release-notes-box {
        max-height: 250px;
    }

    button { padding: 5px 10px; font-size: 0.85rem; }
}

/* Height-resizable box (e.g. the handicap calculator table) — see initBoxResize */
.resizable-box { position: relative; display: inline-block; max-width: 100%; vertical-align: top; }
.resizable-box-scroll { overflow: auto; max-width: 100%; padding-bottom: 4px; }

/* Chart resize handle */
.chart-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: nw-resize;
    background: linear-gradient(-45deg, transparent 0%, transparent 40%, #ccc 40%, #ccc 60%, transparent 60%, transparent 100%);
    z-index: 10;
    opacity: 0.7;
}
.chart-resize-handle:hover {
    opacity: 1;
    background: linear-gradient(-45deg, transparent 0%, transparent 40%, #999 40%, #999 60%, transparent 60%, transparent 100%);
}