/* ── Variables ──────────────────────────────────── */
:root {
    --ocean: #0369a1;
    --ocean-dark: #0c4a6e;
    --ocean-mid: #0ea5e9;
    --ocean-light: #e0f2fe;
    --green: #16a34a;
    --green-light: #dcfce7;
    --red: #dc2626;
    --red-light: #fee2e2;
    --amber: #b45309;
    --amber-light: #fef3c7;
    --blue-note: #1d4ed8;
    --blue-light: #dbeafe;
    --text: #0f172a;
    --muted: #475569;
    --border: #cbd5e1;
    --bg: #f0f9ff;
    --card: #ffffff;
    --radius: 6px;
    --max-w: 1080px;
}

/* ── Reset ──────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
}
body {
    margin: 0;
}
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ── Base ───────────────────────────────────────── */
body {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
        Arial, sans-serif;
    font-size: 16px;
    line-height: 1.75;
    color: var(--text);
    background: var(--bg);
}

a {
    color: var(--ocean);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
    color: var(--ocean-dark);
}

h1,
h2,
h3,
h4 {
    line-height: 1.3;
    font-weight: 700;
    margin: 1.75em 0 0.5em;
}
h1 {
    font-size: 2rem;
    color: var(--ocean-dark);
    margin-top: 0;
}
h2 {
    font-size: 1.45rem;
    color: var(--ocean-dark);
    border-bottom: 2px solid var(--ocean-light);
    padding-bottom: 0.3rem;
}
h3 {
    font-size: 1.1rem;
    color: var(--text);
    margin-top: 1.25em;
}
h4 {
    font-size: 1rem;
    color: var(--muted);
    font-weight: 600;
}

p {
    margin: 0 0 1rem;
}
ul,
ol {
    margin: 0 0 1rem 1.5rem;
}
li {
    margin-bottom: 0.3rem;
}

strong {
    font-weight: 600;
}
hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 2rem 0;
}

blockquote {
    border-left: 4px solid var(--ocean-mid);
    background: var(--ocean-light);
    margin: 1rem 0;
    padding: 0.75rem 1.1rem;
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--muted);
    font-size: 0.95rem;
}
blockquote p {
    margin: 0;
}

/* ── Tables ─────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1rem 0 1.5rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
th {
    background: var(--ocean-dark);
    color: white;
    padding: 0.6rem 0.9rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
td {
    padding: 0.55rem 0.9rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
tr:last-child td {
    border-bottom: none;
}
tr:nth-child(even) td {
    background: #f8fafc;
}
tr:hover td {
    background: var(--ocean-light);
}

/* ── Alert / callout boxes ──────────────────────── */
.note,
.warning,
.permitted,
.prohibited {
    border-radius: var(--radius);
    padding: 0.875rem 1.1rem;
    margin: 1rem 0;
    border-left: 4px solid;
    font-size: 0.9375rem;
}
.note {
    background: var(--blue-light);
    border-color: var(--blue-note);
}
.warning {
    background: var(--amber-light);
    border-color: var(--amber);
}
.permitted {
    background: var(--green-light);
    border-color: var(--green);
}
.prohibited {
    background: var(--red-light);
    border-color: var(--red);
}

.note p,
.warning p,
.permitted p,
.prohibited p {
    margin: 0;
}

/* ── Site Header ────────────────────────────────── */
.site-header {
    background: var(--ocean-dark);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    position: sticky;
    top: 0;
    z-index: 100;
}
.site-header .inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 54px;
    gap: 1rem;
}
.site-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: white;
    white-space: nowrap;
    text-decoration: none;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.site-title:hover {
    text-decoration: none;
    color: white;
}

.site-title .accent {
    color: var(--ocean-mid);
}

.site-nav {
    display: flex;
    gap: 0.1rem;
    flex-wrap: wrap;
}
.site-nav a {
    color: rgba(255, 255, 255, 0.8);
    padding: 0.375rem 0.65rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition:
        background 0.15s,
        color 0.15s;
    white-space: nowrap;
}
.site-nav a:hover,
.site-nav a.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    text-decoration: none;
}

/* ── Page wrapper ───────────────────────────────── */
.page-wrap {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 2rem 1.25rem 3rem;
}

/* ── Hero ───────────────────────────────────────── */
.hero {
    background: linear-gradient(
        150deg,
        var(--ocean-dark) 0%,
        #0369a1 60%,
        #0284c7 100%
    );
    color: white;
    text-align: center;
    padding: 3rem 1.5rem 2.5rem;
}
.hero h1 {
    font-size: clamp(1.75rem, 4vw, 2.8rem);
    color: white;
    margin-bottom: 0.5rem;
}
.hero .subtitle {
    font-size: 1.1rem;
    opacity: 0.88;
    max-width: 600px;
    margin: 0 auto 0.5rem;
}
.hero .meta-line {
    font-size: 0.8rem;
    opacity: 0.65;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 2rem;
}
.hero-map {
    max-width: 820px;
    margin: 0 auto;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
.hero-map img {
    width: 100%;
}

/* ── Cards (homepage navigation) ───────────────── */
.section-label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 2.5rem 0 1rem;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.09);
    padding: 1.4rem 1.25rem;
    text-decoration: none;
    color: var(--text);
    border: 1px solid var(--border);
    transition:
        box-shadow 0.2s,
        transform 0.15s,
        border-color 0.2s;
    display: block;
}
.card:hover {
    box-shadow: 0 4px 14px rgba(3, 105, 161, 0.18);
    border-color: var(--ocean-mid);
    transform: translateY(-2px);
    text-decoration: none;
}
.card-eyebrow {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ocean-mid);
    margin-bottom: 0.3rem;
}
.card h3 {
    margin: 0 0 0.4rem;
    font-size: 1.05rem;
    color: var(--ocean-dark);
    line-height: 1.3;
}
.card p {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0;
    line-height: 1.5;
}

/* ── Emergency box ──────────────────────────────── */
.emergency {
    background: var(--red-light);
    border: 2px solid var(--red);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin: 2rem 0;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}
.emergency-body h3 {
    color: var(--red);
    margin: 0 0 0.3rem;
    font-size: 1rem;
}
.emergency-body p {
    margin: 0;
    font-size: 0.9rem;
}
.emergency-body .phone {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--red);
    letter-spacing: 0.03em;
}

/* ── Breadcrumb ──────────────────────────────────── */
.breadcrumb {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 1.5rem;
}
.breadcrumb a {
    color: var(--ocean);
}

/* ── Content card ────────────────────────────────── */
.content-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.09);
    padding: 2rem 2.5rem;
    border: 1px solid var(--border);
}
@media (max-width: 600px) {
    .content-card {
        padding: 1.25rem;
    }
}

/* ── Page TOC ────────────────────────────────────── */
.page-toc {
    background: var(--ocean-light);
    border: 1px solid #bae6fd;
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin: 0 0 2rem;
    font-size: 0.875rem;
}
.page-toc strong {
    display: block;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ocean-dark);
    margin-bottom: 0.5rem;
}
.page-toc ul {
    margin: 0;
    padding-left: 1.25rem;
}
.page-toc li {
    margin-bottom: 0.2rem;
}
.page-toc a {
    color: var(--ocean);
}

/* ── Map figures ──────────────────────────────────── */
figure.map-fig {
    margin: 1.25rem 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}
figure.map-fig img {
    width: 100%;
}
figure.map-fig figcaption {
    background: #f8fafc;
    border-top: 1px solid var(--border);
    padding: 0.4rem 0.85rem;
    font-size: 0.78rem;
    color: var(--muted);
    font-style: italic;
}

/* ── Species photo thumbnails (in tables) ─────────── */
.species-thumb {
    width: 150px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border);
    display: block;
}
td:has(.species-thumb) {
    vertical-align: middle;
    width: 200px;
    height: 120px;
    padding: 0.35rem 0.5rem;
}

/* ── Inline species images ───────────────────────── */
figure.species-fig {
    float: right;
    margin: 0 0 1.25rem 1.5rem;
    max-width: 270px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    clear: right;
}
figure.species-fig img {
    width: 100%;
}
figure.species-fig figcaption {
    background: #f8fafc;
    border-top: 1px solid var(--border);
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    color: var(--muted);
    font-style: italic;
}
.clearfix::after {
    content: "";
    display: table;
    clear: both;
}
@media (max-width: 540px) {
    figure.species-fig {
        float: none;
        max-width: 100%;
        margin: 0 0 1rem;
    }
}

/* ── Island grid (areas overview) ────────────────── */
.island-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}
.island-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1rem;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s;
    display: block;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
}
.island-card:hover {
    border-color: var(--ocean-mid);
    box-shadow: 0 4px 12px rgba(3, 105, 161, 0.15);
    transform: translateY(-2px);
    text-decoration: none;
}
.island-card h3 {
    color: var(--ocean-dark);
    margin: 0.25rem 0;
    font-size: 1rem;
}
.island-card p {
    font-size: 0.8rem;
    color: var(--muted);
    margin: 0;
    line-height: 1.4;
}

/* ── Site Footer ─────────────────────────────────── */
.site-footer {
    background: var(--ocean-dark);
    color: rgba(255, 255, 255, 0.65);
    text-align: center;
    padding: 1.75rem 1rem;
    font-size: 0.82rem;
    margin-top: 3rem;
}
.site-footer p {
    margin: 0.2rem 0;
}
.site-footer a {
    color: rgba(255, 255, 255, 0.8);
}
.site-footer a:hover {
    color: white;
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 720px) {
    .site-header .inner {
        flex-wrap: wrap;
        padding: 0.4rem 1rem;
        min-height: auto;
        gap: 0.4rem;
    }
    .site-nav a {
        padding: 0.3rem 0.5rem;
        font-size: 0.8rem;
    }
    h1 {
        font-size: 1.6rem;
    }
    h2 {
        font-size: 1.25rem;
    }
    .page-wrap {
        padding: 1rem 0.875rem 2rem;
    }
    .cards {
        grid-template-columns: 1fr 1fr;
    }
    table {
        font-size: 0.8rem;
    }
}
@media (max-width: 480px) {
    .cards {
        grid-template-columns: 1fr;
    }
    .island-grid {
        grid-template-columns: 1fr 1fr;
    }
    .emergency {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* ── Search ──────────────────────────────────────── */
.search-wrap {
    margin: 1.5rem 0;
}
.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    background: var(--card);
    color: var(--text);
    box-sizing: border-box;
}
.search-input:focus {
    border-color: var(--ocean-mid);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}
.search-status {
    font-size: 0.875rem;
    color: var(--muted);
    margin-bottom: 1rem;
}
.search-result-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.search-result {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
}
.search-result-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ocean-dark);
    text-decoration: none;
    display: block;
    margin-bottom: 0.3rem;
}
.search-result-title:hover {
    text-decoration: underline;
}
.search-result-snippet {
    font-size: 0.875rem;
    color: var(--muted);
    margin: 0;
    line-height: 1.6;
}
.search-result-snippet mark {
    background: #fef08a;
    color: var(--text);
    border-radius: 2px;
    padding: 0 2px;
}

/* ── Ask AI ──────────────────────────────────────── */
.ask-subtitle {
    color: var(--muted);
    margin-top: -0.5rem;
    margin-bottom: 1.5rem;
}
.api-key-warning {
    background: var(--amber-light);
    border: 1px solid var(--amber);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: var(--text);
    margin-bottom: 1.25rem;
}
.api-key-section {
    background: var(--ocean-light);
    border: 1px solid #bae6fd;
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.75rem;
}
.api-key-label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}
.api-key-hint {
    display: block;
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.1rem;
}
.api-key-row {
    display: flex;
    gap: 0.5rem;
}
.api-key-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    background: var(--card);
    color: var(--text);
    font-family: monospace;
}
.api-key-input:focus {
    border-color: var(--ocean-mid);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}
.btn-save {
    padding: 0.5rem 1rem;
    background: var(--ocean);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}
.btn-save:hover {
    background: var(--ocean-dark);
}
.btn-delete {
    padding: 0.5rem 1rem;
    background: transparent;
    color: var(--red);
    border: 1px solid var(--red);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}
.btn-delete:hover {
    background: var(--red-light);
}
.api-key-status {
    font-size: 0.8rem;
    color: var(--muted);
    margin: 0.4rem 0 0;
}
.ask-form {
    margin-bottom: 1.5rem;
}
.question-label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}
.question-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    background: var(--card);
    color: var(--text);
    resize: vertical;
    box-sizing: border-box;
    font-family: inherit;
    line-height: 1.5;
    margin-bottom: 0.75rem;
}
.question-input:focus {
    border-color: var(--ocean-mid);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}
.btn-ask {
    padding: 0.6rem 1.5rem;
    background: var(--ocean-dark);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-ask:hover:not(:disabled) {
    background: var(--ocean);
}
.btn-ask:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.answer-section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1rem;
}
.answer-label {
    background: var(--ocean-dark);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.4rem 1rem;
}
.answer-body {
    padding: 1rem 1.25rem;
    font-size: 0.975rem;
    line-height: 1.75;
    white-space: pre-wrap;
    min-height: 3rem;
}
.answer-footer {
    border-top: 1px solid var(--border);
    padding: 0.5rem 1.25rem;
    font-size: 0.78rem;
    color: var(--muted);
}
.ask-error {
    background: var(--red-light);
    border: 1px solid var(--red);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    color: var(--red);
}
