/* weather-modern.css — modern look for weather.php (desktop + mobile)
   Everything is scoped under .cw (page) or .cw-history (modal table). */

.cw {
  --cw-ink: #0f1b2d;
  --cw-muted: #5b6b82;
  --cw-line: #e4e9f1;
  --cw-surface: #ffffff;
  --cw-accent: #0b7285;
  --cw-accent-dark: #0a4f66;
  --cw-radius: 16px;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 12px 48px;
  color: var(--cw-ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
.cw *, .cw *::before, .cw *::after { box-sizing: border-box; }

/* ---------- Hero ---------- */
.cw-hero {
  background: linear-gradient(135deg, #0a3d62 0%, #0b7285 100%);
  color: #fff;
  border-radius: 20px;
  padding: 24px 20px;
  margin-bottom: 20px;
  box-shadow: 0 12px 32px -14px rgba(10, 61, 98, .55);
}
.cw-eyebrow {
  margin: 0 0 4px;
  font-size: .8rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .8;
}
.cw .cw-hero h1 {
  margin: 0;
  color: #fff;
  text-align: left;
  font-size: clamp(1.5rem, 4.5vw, 2.25rem);
  font-weight: 750;
  letter-spacing: -.02em;
  line-height: 1.15;
}
.cw-hero-sub { margin: 6px 0 0; opacity: .85; font-size: .95rem; }

.cw-route {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cw-route li {
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: .85rem;
  white-space: nowrap;
}
.cw-route li:not(:last-child)::after { content: "\2192"; margin-left: 8px; opacity: .65; }

.cw-hero-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

/* ---------- Buttons ---------- */
.cw .cw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, transform .05s;
}
.cw .cw-btn:active { transform: translateY(1px); }
.cw .cw-btn:focus-visible, .cw summary:focus-visible, .cw-search input:focus-visible {
  outline: 3px solid rgba(11, 114, 133, .45);
  outline-offset: 2px;
}
.cw .cw-btn-primary { background: var(--cw-accent); color: #fff; }
.cw .cw-btn-primary:hover { background: var(--cw-accent-dark); color: #fff; text-decoration: none; }
.cw .cw-btn-ghost { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .4); }
.cw .cw-btn-ghost:hover { background: rgba(255, 255, 255, .26); color: #fff; text-decoration: none; }
.cw .cw-btn-soft { background: #e6f3f6; color: var(--cw-accent-dark); }
.cw .cw-btn-soft:hover { background: #d3eaf0; color: var(--cw-accent-dark); text-decoration: none; }
.cw .cw-btn-danger { background: #fff; color: #b42318; border-color: #f1c2bd; }
.cw .cw-btn-danger:hover { background: #fef3f2; }
.cw .cw-btn-sm { min-height: 38px; padding: 0 14px; font-size: .85rem; }

/* ---------- Search ---------- */
.cw-search { margin-top: 18px; }
.cw-search input {
  width: 100%;
  height: 48px;
  padding: 0 16px 0 46px;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 14px;
  font-size: 16px; /* 16px stops iOS from zooming on focus */
  color: var(--cw-ink);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%235b6b82' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 16px center;
}

/* ---------- Day cards ---------- */
.cw .card {
  background: var(--cw-surface);
  border: 1px solid var(--cw-line);
  border-radius: var(--cw-radius);
  margin: 0 0 16px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 27, 45, .04), 0 10px 26px -18px rgba(15, 27, 45, .25);
}
.cw .card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(180deg, #f6fafd, #fff);
  border-bottom: 1px solid var(--cw-line);
}
.cw .header-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cw .location {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--cw-ink);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.cw a.location:hover { color: var(--cw-accent); text-decoration: underline; }
.cw .date-line { color: var(--cw-muted); font-size: .875rem; }
.cw .weather-icon { width: 56px; height: 56px; margin: -6px 0; flex: none; }
.cw .card-body { padding: 16px; }

.cw-badge {
  flex: none;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.cw-badge-port { background: #e0f2fe; color: #075985; }
.cw-badge-sea  { background: #ede9fe; color: #5b21b6; }

/* ---------- Metric tiles ---------- */
.cw-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.cw-tile {
  --t-bg: #f3f6fa; --t-line: #dde4ee; --t-ink: #3b4a60;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 12px 14px;
  background: var(--t-bg);
  border: 1px solid var(--t-line);
  border-radius: 12px;
}
.cw-tile-temp, .cw-tile-sun { grid-column: 1 / -1; }
.cw-label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--t-ink);
}
.cw-value { font-size: 1.4rem; font-weight: 750; letter-spacing: -.01em; line-height: 1.2; color: var(--cw-ink); }
.cw-value small { font-size: .75rem; font-weight: 600; color: var(--cw-muted); letter-spacing: 0; }
.cw-sub { font-size: .8rem; color: var(--cw-muted); overflow-wrap: anywhere; }
.cw-note { margin: 10px 2px 0; font-size: .8rem; color: var(--cw-muted); }

/* Same thresholds as before: green / yellow / orange / pink */
.cw-tone-good { --t-bg: #ecfdf3; --t-line: #b7ebcb; --t-ink: #166534; }
.cw-tone-ok   { --t-bg: #fefce8; --t-line: #f4e49a; --t-ink: #854d0e; }
.cw-tone-warn { --t-bg: #fff4ed; --t-line: #fbd0b0; --t-ink: #9a3412; }
.cw-tone-bad  { --t-bg: #fdf2fa; --t-line: #f0c3e8; --t-ink: #86198f; }

/* ---------- Ships in port ---------- */
.cw-ships { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 14px; }
.cw-ships-label { font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--cw-muted); margin-right: 4px; }
.cw-chip {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: #eef3f8;
  color: var(--cw-ink);
  font-size: .85rem;
  text-decoration: none;
}
.cw a.cw-chip:hover { background: #dbe8f3; text-decoration: none; color: var(--cw-ink); }
.cw-chip-none { background: transparent; color: var(--cw-muted); padding-left: 0; }

/* ---------- Actions row ---------- */
.cw-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.cw-actions form { margin: 0; margin-left: auto; }
.cw details { flex: 1 1 100%; order: 3; }
.cw summary {
  display: inline-block;
  list-style: none;
  cursor: pointer;
  padding: 8px 0;
  font-size: .85rem;
  font-weight: 600;
  color: var(--cw-accent);
}
.cw summary::-webkit-details-marker { display: none; }
.cw summary::before { content: "\25B8"; display: inline-block; margin-right: 6px; transition: transform .15s; }
.cw details[open] summary::before { transform: rotate(90deg); }
.cw details pre {
  max-height: 280px;
  overflow: auto;
  margin: 4px 0 0;
  padding: 12px;
  border-radius: 10px;
  background: #0f1b2d;
  color: #d7e3f4;
  font-size: .75rem;
}
.cw-empty { margin: 0; color: var(--cw-muted); }

/* ---------- Sailings list ---------- */
.cw .table { width: 100%; margin: 0; border-collapse: separate; border-spacing: 0; background: transparent; }
.cw #sailingsTable {
  background: var(--cw-surface);
  border: 1px solid var(--cw-line);
  border-radius: var(--cw-radius);
  overflow: hidden;
  box-shadow: 0 10px 26px -18px rgba(15, 27, 45, .25);
}
.cw #sailingsTable thead th {
  padding: 12px 16px;
  background: #f6fafd;
  border: 0;
  border-bottom: 1px solid var(--cw-line);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--cw-muted);
  text-align: left;
}
.cw #sailingsTable thead th:last-child { text-align: right; }
.cw #sailingsTable tbody tr,
.cw #sailingsTable.table-striped tbody tr:nth-of-type(odd) { background: transparent; }
.cw #sailingsTable tbody tr:hover { background: #f8fbfd; }
.cw #sailingsTable td { padding: 14px 16px; vertical-align: middle; border: 0; border-top: 1px solid var(--cw-line); }
.cw #sailingsTable tbody tr:first-child td { border-top: 0; }
.cw #sailingsTable td:first-child { font-weight: 700; }
.cw #sailingsTable td:last-child { white-space: nowrap; text-align: right; }
.cw .port-list { margin: 4px 0 0; font-size: .8rem; font-weight: 400; color: var(--cw-muted); }
.cw-alert { padding: 16px; border-radius: 12px; background: #eef6fb; color: #0a4f66; }

/* ---------- Mobile ---------- */
@media (min-width: 640px) {
  .cw { padding: 24px 16px 56px; }
  .cw-hero { padding: 32px 32px; }
  .cw .card-body { padding: 20px; }
  .cw-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cw-tile-temp, .cw-tile-sun { grid-column: auto; }
  .cw details { flex: 0 0 auto; order: 0; }
  .cw details[open] { flex: 1 1 100%; order: 3; }
}
@media (max-width: 639px) {
  .cw .weather-icon { width: 48px; height: 48px; }
  .cw-hero-actions .cw-btn { flex: 1 1 auto; }

  /* Sailings table turns into stacked cards (same markup, so search still works) */
  .cw #sailingsTable { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .cw #sailingsTable thead { display: none; }
  .cw #sailingsTable, .cw #sailingsTable tbody { display: block; }
  .cw #sailingsTable tbody tr {
    display: block;
    margin-bottom: 12px;
    padding: 4px 0;
    background: var(--cw-surface);
    border: 1px solid var(--cw-line);
    border-radius: var(--cw-radius);
    box-shadow: 0 8px 22px -18px rgba(15, 27, 45, .3);
  }
  .cw #sailingsTable td { display: block; border: 0; padding: 8px 16px; text-align: left !important; }
  .cw #sailingsTable td:nth-child(2) { color: var(--cw-muted); font-size: .9rem; padding-top: 0; }
  .cw #sailingsTable td:last-child { padding-bottom: 14px; }
  .cw #sailingsTable td:last-child .cw-btn { width: 100%; margin-bottom: 6px; }
}

/* ---------- History modal table ---------- */
.cw-history { font-size: .9rem; }
.cw-history th { font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; color: #5b6b82; white-space: nowrap; }
.cw-history td { white-space: nowrap; }
.cw-history .cw-current td { font-weight: 700; }
.cw-history .cw-cell-good { background: #ecfdf3; }
.cw-history .cw-cell-ok   { background: #fefce8; }
.cw-history .cw-cell-warn { background: #fff4ed; }
.cw-history .cw-cell-bad  { background: #fdf2fa; }

@media (prefers-reduced-motion: reduce) {
  .cw *, .cw *::before { transition: none !important; }
}
