/* The platform dock (docs/competition/PLAN.md phase 3): one navigation for the public site, built by public/dock.js into
   <nav id="dock">. Pages: /, /competition, /try, /naseej, /templates, /nerve and the 404 page.
   Desktop: a floating glass pill at the bottom center, light glass on light pages and dark glass on night pages.
   Phones (<= 700px): a full width app bar with the raised round gold «أرسل روايتك» in the middle.
   Every page that carries it keeps its space: --dock-space (body.dock-pad, or the page layout itself on /competition). */

:root {
  --dock-h: 58px;
  --dock-gap: 14px;
  --dock-space: calc(var(--dock-h) + var(--dock-gap) * 2 + env(safe-area-inset-bottom, 0px));
}
.dock-pad { padding-bottom: var(--dock-space) }

.dock {
  --d-bg: rgba(255, 255, 255, .84); --d-line: rgba(23, 32, 58, .1); --d-ink: #5E6880; --d-ink-h: #17203A;
  --d-on-bg: #17203A; --d-on-ink: #F6F4EE; --d-shadow: 0 20px 44px -20px rgba(23, 32, 58, .45); --d-ring: #F6F4EE;
  position: fixed; z-index: 42; left: 50%; bottom: calc(var(--dock-gap) + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  height: var(--dock-h); display: flex; align-items: center; gap: 2px; padding: 6px; border-radius: 999px;
  background: var(--d-bg); border: 1px solid var(--d-line); box-shadow: var(--d-shadow);
  -webkit-backdrop-filter: blur(18px) saturate(1.5); backdrop-filter: blur(18px) saturate(1.5);
  font-family: var(--text, 'IBM Plex Sans Arabic', system-ui, sans-serif); direction: rtl;
  transition: background .4s, border-color .4s, box-shadow .4s
}
[data-theme="dark"] .dock {
  --d-bg: rgba(14, 21, 40, .84); --d-line: rgba(46, 61, 110, .75); --d-ink: #97A0B4; --d-ink-h: #F2ECDD;
  --d-on-bg: #F2ECDD; --d-on-ink: #070B17; --d-shadow: 0 20px 44px -18px #000; --d-ring: #070B17
}
/* Before the script fills it, the box keeps its size so nothing moves when it does. */
.dock:empty { visibility: hidden; width: min(560px, calc(100vw - 32px)) }
.dock[hidden] { display: none }

.dock a, .dock button {
  position: relative; display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 15px; border: 0; border-radius: 999px;
  background: none; color: var(--d-ink); font-family: inherit; font-size: 14px; font-weight: 600; line-height: 1; text-decoration: none; cursor: pointer;
  white-space: nowrap; transition: background .3s, color .3s, padding .4s; -webkit-tap-highlight-color: transparent
}
.dock a:hover, .dock button:hover { color: var(--d-ink-h) }
.dock a:focus-visible, .dock button:focus-visible { outline: 2px solid #D2A24C; outline-offset: 2px }
.dock svg { width: 20px; height: 20px; flex: none }
.dock .lb { max-width: 130px; overflow: hidden; white-space: nowrap; transition: max-width .4s cubic-bezier(.2, .8, .2, 1), opacity .3s }
.dock .ind { display: none }
.dock .fab { display: contents }
.dock .sep { width: 1px; height: 26px; background: rgba(127, 135, 160, .3); margin: 0 4px; flex: none }
.dock [aria-current="page"], .dock .open, .dock .here { background: var(--d-on-bg); color: var(--d-on-ink) }
.dock [aria-current="page"]:hover, .dock .open:hover, .dock .here:hover { color: var(--d-on-ink) }
.dock a.go { background: #D2A24C; color: #14203A; margin-inline: 4px }
.dock a.go:hover { color: #14203A; filter: brightness(1.07) }
.dock a.go[aria-current="page"] { box-shadow: inset 0 0 0 2px var(--d-on-bg) }
/* While reading down the labels fold to icons; scrolling up brings them back (desktop only, public/dock.js). */
.dock.mini a:not([aria-current]):not(.go) .lb, .dock.mini button:not(.open):not(.here) .lb { max-width: 0; opacity: 0 }
.dock.mini a:not([aria-current]):not(.go), .dock.mini button:not(.open):not(.here) { padding: 0 13px; gap: 0 }

/* the "more" sheet: a dialog above the dock */
.dock-bg { position: fixed; inset: 0; z-index: 1000; background: rgba(7, 11, 23, .45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); opacity: 0; transition: opacity .3s }
.dock-sheet {
  --s-bg: #FFFFFF; --s-line: rgba(23, 32, 58, .1); --s-ink: #17203A; --s-on-bg: #17203A; --s-on-ink: #F6F4EE;
  position: fixed; z-index: 1001; left: 50%; bottom: calc(var(--dock-h) + var(--dock-gap) * 2 + env(safe-area-inset-bottom, 0px));
  width: min(360px, calc(100vw - 24px)); transform: translate(-50%, 16px) scale(.97); opacity: 0;
  transition: transform .35s cubic-bezier(.2, .8, .2, 1), opacity .25s; border-radius: 22px; padding: 10px;
  background: var(--s-bg); border: 1px solid var(--s-line); box-shadow: 0 30px 60px -24px rgba(23, 32, 58, .5); color: var(--s-ink);
  font-family: var(--text, 'IBM Plex Sans Arabic', system-ui, sans-serif); direction: rtl
}
[data-theme="dark"] .dock-sheet { --s-bg: #111A30; --s-line: #2E3D6E; --s-ink: #ECE5D4; --s-on-bg: #F2ECDD; --s-on-ink: #070B17 }
.dock-bg[hidden], .dock-sheet[hidden] { display: none }
.dock-bg.on { opacity: 1 }
.dock-sheet.on { transform: translate(-50%, 0) scale(1); opacity: 1 }
.dock-sheet a, .dock-sheet .row-t, .dock-sheet .soon-i {
  display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 10px 14px; border-radius: 14px; font-size: 15px; font-weight: 600;
  text-decoration: none; color: inherit
}
.dock-sheet a:hover { background: rgba(127, 135, 160, .12) }
.dock-sheet a:focus-visible, .dock-sheet button:focus-visible { outline: 2px solid #D2A24C; outline-offset: 1px }
.dock-sheet a[aria-current="page"] { background: rgba(127, 135, 160, .14) }
.dock-sheet svg { width: 20px; height: 20px; opacity: .75; flex: none }
.dock-sheet .soon-i { opacity: .8 }
.dock-sheet small { margin-inline-start: auto; font-size: 11.5px; font-weight: 600; color: #B8862E; border: 1px solid rgba(210, 162, 76, .45); padding: 1px 8px; border-radius: 999px }
[data-theme="dark"] .dock-sheet small { color: #D8B466 }
.dock-sheet small.beta { margin-inline-start: 0 } /* beside its name, not at the far end */
.dock-sheet hr { border: 0; border-top: 1px solid rgba(127, 135, 160, .2); margin: 6px 8px }
.dock-sheet .row-t { justify-content: space-between }
.dock-sheet .row-t > span:first-child { display: flex; align-items: center; gap: 12px }
.dock-sheet .seg2 { display: flex; gap: 3px; padding: 3px; border-radius: 999px; background: rgba(127, 135, 160, .14) }
.dock-sheet .seg2 button { border: 0; background: transparent; color: inherit; opacity: .7; font-family: inherit; font-size: 13px; font-weight: 600; padding: 6px 13px; border-radius: 999px; cursor: pointer; min-height: 32px }
.dock-sheet .seg2 button[aria-pressed="true"] { opacity: 1; background: var(--s-on-bg); color: var(--s-on-ink) }
.dock-sheet .note { margin: 2px 14px 6px; font-size: 12px; line-height: 1.7; opacity: .7 }

/* Floating helpers of the pages stay above the dock (the inquiry button on every public page). */
.dock-pad .iq-fab { bottom: calc(var(--dock-space) + 10px) }
.dock-pad .iq-badge { bottom: calc(var(--dock-space) + 60px) }

/* ---------- phones: the dock becomes a full width app bar ---------- */
@media (max-width: 700px) {
  :root { --dock-h: 62px; --dock-gap: 0px }
  .dock {
    left: 0; right: 0; transform: none; bottom: 0; height: auto; min-height: calc(var(--dock-h) + env(safe-area-inset-bottom, 0px));
    border-radius: 22px 22px 0 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px)); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0; border-inline: 0; border-bottom: 0
  }
  .dock:empty { width: auto }
  .dock a, .dock button { flex-direction: column; justify-content: center; height: 50px; padding: 0 2px; gap: 3px; font-size: 11px; border-radius: 14px; min-width: 0 }
  .dock .lb { max-width: 100%; text-overflow: ellipsis }
  .dock [aria-current="page"], .dock .open, .dock .here { background: none; color: var(--d-on-bg) }
  [data-theme="dark"] .dock [aria-current="page"], [data-theme="dark"] .dock .open, [data-theme="dark"] .dock .here { color: #D8B466 }
  .dock [aria-current="page"] .ind, .dock .open .ind, .dock .here .ind { display: block; position: absolute; top: -6px; left: 50%; margin-left: -12px; width: 24px; height: 3px; border-radius: 3px; background: var(--d-on-bg) }
  [data-theme="dark"] .dock [aria-current="page"] .ind, [data-theme="dark"] .dock .open .ind, [data-theme="dark"] .dock .here .ind { background: #D8B466; box-shadow: 0 0 10px #D8B466 }
  .dock a.go, .dock a.go:hover { background: none; margin: 0; color: var(--d-on-bg); filter: none; box-shadow: none }
  [data-theme="dark"] .dock a.go { color: #F2ECDD }
  .dock a.go .fab {
    display: flex; align-items: center; justify-content: center; width: 52px; height: 52px; margin-top: -30px; border-radius: 50%;
    background: #D2A24C; color: #14203A; box-shadow: 0 10px 24px -8px rgba(138, 97, 20, .7), 0 0 0 5px var(--d-ring)
  }
  .dock a.go .fab svg { width: 22px; height: 22px }
  .dock a.go[aria-current="page"] { box-shadow: none }
  .dock a.go[aria-current="page"] .ind { display: none }
  .dock a.go[aria-current="page"] .fab { box-shadow: 0 10px 24px -8px rgba(138, 97, 20, .7), 0 0 0 5px var(--d-ring), 0 0 0 7px #D2A24C }
  .dock.mini a .lb, .dock.mini button .lb { max-width: 100%; opacity: 1 }
  .dock-sheet { left: 12px; right: 12px; width: auto; transform: translateY(20px); bottom: calc(var(--dock-h) + 12px + env(safe-area-inset-bottom, 0px)) }
  .dock-sheet.on { transform: none }

  /* /competition on phones: ONE bar. «كوب» home on the start side, a divider, then the five tabs of the page
     (the tab buttons are added by public/competition.js). */
  .dock.comp { grid-template-columns: 48px 1px repeat(5, minmax(0, 1fr)) }
  .dock.comp .sep { height: 30px; margin: 0; align-self: center }
  .dock.comp [aria-selected="true"] { color: #D8B466 }
  .dock.comp [aria-selected="true"] .ind { display: block; position: absolute; top: -6px; left: 50%; margin-left: -12px; width: 24px; height: 3px; border-radius: 3px; background: #D8B466; box-shadow: 0 0 10px #D8B466 }
}

@media (prefers-reduced-motion: reduce) {
  .dock, .dock *, .dock-bg, .dock-sheet { transition: none !important }
}
