/* Hvilepuls på nett. Mål i px tilsvarer punkter (pt) i iOS-appen. */

@font-face { font-family: "Pirata One"; src: url("../fonts/PirataOne-Regular.ttf") format("truetype"); font-display: block; }
@font-face { font-family: "Rye"; src: url("../fonts/Rye-Regular.ttf") format("truetype"); font-display: block; }

:root {
  --paper: 240 232 214;
  --paper-warm: 245 238 221;
  --card: 250 246 236;
  --ink: 42 37 29;
  --ink2: 74 67 55;
  --ink-secondary: 107 99 87;
  --ink-muted: 158 148 135;
  --ink-whisper: 198 190 172;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --serif: ui-serif, "New York", "Iowan Old Style", "Charter", Georgia, "Noto Serif", serif;
  --sans: -apple-system, BlinkMacSystemFont, system-ui, "SF Pro Text", "Helvetica Neue", Roboto, "Segoe UI", sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: rgb(var(--paper-warm));
  color: rgb(var(--ink));
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.2;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#app { position: fixed; inset: 0; overflow: hidden; }

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: inherit; }
button:disabled { cursor: default; }
input, textarea { -webkit-user-select: text; user-select: text; }
canvas { -webkit-user-select: none; user-select: none; }
:focus { outline: none; }
:focus-visible { outline: 2px solid rgb(var(--ink) / 0.35); outline-offset: 2px; border-radius: 6px; }

.row { display: flex; flex-direction: row; }
.col { display: flex; flex-direction: column; }
.center { align-items: center; justify-content: center; }
.spacer { flex: 1 1 0; min-width: 0; min-height: 0; }
.fill { position: absolute; inset: 0; }
.no-scrollbar { scrollbar-width: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }
.scroll { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; scrollbar-width: none; }
.scroll::-webkit-scrollbar { display: none; }

/* Skjerm: full flate med trygge marger, som en SwiftUI-rotview. */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; overflow: hidden; }
.safe-top { padding-top: var(--sat); }
.safe-bottom { padding-bottom: var(--sab); }
.safe-x { padding-left: var(--sal); padding-right: var(--sar); }

.pressable { display: inline-flex; align-items: center; justify-content: center; transition: transform .2s cubic-bezier(0,0,.58,1), opacity .2s; touch-action: manipulation; }
.pressable.plain:active { opacity: .65; }

/* MARK: - Navigasjon */

.nav-root { position: absolute; inset: 0; overflow: hidden; background: #000; }
.nav-base { position: absolute; inset: 0; transition: transform .42s cubic-bezier(.32,.72,0,1), filter .42s; }
.nav-base.shifted { transform: translateX(-30%); filter: brightness(.92); }

.push-layer, .cover-layer { position: absolute; inset: 0; will-change: transform; }
.push-layer { transform: translateX(100%); transition: transform .42s cubic-bezier(.32,.72,0,1), filter .42s; box-shadow: -8px 0 24px rgba(0,0,0,.08); }
.push-layer.in { transform: translateX(0); }
.push-layer.shifted { transform: translateX(-30%); filter: brightness(.92); }
.cover-layer { transform: translateY(100%); transition: transform .48s cubic-bezier(.32,.72,0,1), filter .42s; }
.cover-layer.in { transform: translateY(0); }
.cover-layer.in.shifted { transform: translateX(-30%); filter: brightness(.92); }

.nav-base.behind-sheet, .push-layer.in.behind-sheet, .cover-layer.in.behind-sheet {
  transform: translateY(calc(var(--sat) * 0.6)) scale(.92); border-radius: 12px; overflow: hidden; filter: brightness(.94); }
.sheet-layer { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
.sheet-layer.in { pointer-events: auto; }
.sheet-dim { position: absolute; inset: 0; background: rgba(0,0,0,.2); opacity: 0; transition: opacity .42s; }
.sheet-layer.in .sheet-dim { opacity: 1; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 12px 12px 0 0; transform: translateY(100%);
  transition: transform .42s cubic-bezier(.32,.72,0,1); display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 -2px 20px rgba(0,0,0,.08); padding-bottom: var(--sab); }
.sheet.large { top: calc(var(--sat) + 10px); border-radius: 12px 12px 0 0; }
.sheet.detent { border-radius: 16px 16px 0 0; }
.sheet-layer.in .sheet { transform: translateY(0); }
.sheet-grabber { position: absolute; top: 5px; left: 50%; width: 36px; height: 5px; margin-left: -18px; border-radius: 3px; background: rgba(60,60,67,.3); z-index: 3; }
.sheet-body { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
@media (min-width: 700px) {
  .sheet { left: 50%; right: auto; width: 600px; margin-left: -300px; }
}

.alert-layer { position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.alert-layer.in { pointer-events: auto; }
.alert-dim { position: absolute; inset: 0; background: rgba(0,0,0,.2); opacity: 0; transition: opacity .22s; }
.alert-layer.in .alert-dim { opacity: 1; }
.alert { position: relative; width: 270px; border-radius: 14px; overflow: hidden; background: rgba(242,242,242,.94);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); transform: scale(1.12); opacity: 0;
  transition: transform .22s cubic-bezier(.2,.9,.3,1), opacity .22s; font-family: var(--sans); color: #000; }
.alert-layer.in .alert { transform: scale(1); opacity: 1; }
.alert-text { padding: 19px 16px 18px; text-align: center; }
.alert-title { font-size: 17px; font-weight: 600; line-height: 1.3; }
.alert-message { font-size: 13px; margin-top: 3px; line-height: 1.35; }
.alert-buttons { display: flex; flex-direction: column; border-top: 0.5px solid rgba(60,60,67,.29); }
.alert-buttons.row { flex-direction: row; }
.alert-button { flex: 1 1 0; height: 44px; font-size: 17px; color: #007aff; text-align: center; }
.alert-buttons.row .alert-button + .alert-button { border-left: 0.5px solid rgba(60,60,67,.29); }
.alert-buttons:not(.row) .alert-button + .alert-button { border-top: 0.5px solid rgba(60,60,67,.29); }
.alert-button.cancel { font-weight: 600; }
.alert-button.destructive { color: #ff3b30; }
.alert-button:active { background: rgba(0,0,0,.06); }

/* MARK: - iOS-kontroller */

.ios-toggle { position: relative; width: 51px; height: 31px; border-radius: 16px; background: rgba(120,120,128,.16);
  transition: background .25s; flex: none; }
.ios-toggle.on { background: var(--tint); }
.ios-toggle .knob { position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,.15), 0 3px 1px rgba(0,0,0,.06); transition: transform .25s cubic-bezier(.3,.7,.4,1.1); }
.ios-toggle.on .knob { transform: translateX(20px); }
.ios-toggle:disabled { opacity: .5; }

.ios-seg { position: relative; display: flex; height: 32px; padding: 2px; border-radius: 9px; background: rgba(118,118,128,.12);
  font-family: var(--sans); font-size: 13px; color: #000; flex: none; }
.ios-seg-thumb { position: absolute; top: 2px; bottom: 2px; left: 2px; width: calc((100% - 4px) / var(--n)); border-radius: 7px; background: #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 3px 1px rgba(0,0,0,.04), 0 0 0 .5px rgba(0,0,0,.04);
  transform: translateX(calc(100% * var(--i))); transition: transform .28s cubic-bezier(.3,.7,.3,1); }
.ios-seg-item { position: relative; flex: 1 1 0; min-width: 0; text-align: center; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; }
.ios-seg-item.on { font-weight: 600; }
.ios-seg[aria-disabled="true"] { opacity: 1; }

.ios-wheel { position: relative; overflow: hidden; font-family: var(--sans); font-size: 21px; color: #000;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 35%, #000 65%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 35%, #000 65%, transparent 100%); }
.ios-wheel-band { position: absolute; left: 0; right: 0; border-radius: 8px; background: rgba(118,118,128,.12); pointer-events: none; }
.ios-wheel-scroll { position: absolute; inset: 0; overflow-y: auto; scroll-snap-type: y mandatory; scrollbar-width: none; overscroll-behavior: contain; }
.ios-wheel-scroll::-webkit-scrollbar { display: none; }
.ios-wheel-row { display: flex; align-items: center; justify-content: center; scroll-snap-align: center; opacity: .45; transition: opacity .15s; }
.ios-wheel-row.on { opacity: 1; }

.ios-spinner { position: relative; display: inline-block; }
.ios-spinner i { position: absolute; left: 50%; top: 0; width: 8%; height: 28%; margin-left: -4%; border-radius: 1px; background: currentColor;
  transform-origin: 50% 178%; opacity: .25; animation: ios-spin .8s linear infinite; }
@keyframes ios-spin { 0% { opacity: 1; } 100% { opacity: .2; } }

/* MARK: - Papir */

.rhythm-pill { display: inline-flex; align-items: center; gap: 3px; border-radius: 999px; }
.rhythm-chip { display: inline-flex; align-items: baseline; gap: 4px; }
.favorite-prompt { display: flex; flex-direction: column; align-items: center; }

.fade-in { animation: fade-in .35s ease-in-out both; }
.fade-slide-in { animation: fade-slide-in .35s ease-in-out both; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-slide-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

textarea, input[type="text"] { font: inherit; color: inherit; background: transparent; border: 0; outline: none; resize: none; padding: 0; margin: 0; caret-color: rgb(var(--ink)); }
textarea::placeholder, input::placeholder { color: rgb(var(--ink-muted)); opacity: 1; }

/* Ro: den myke fyllingen i sirkelen puster 1,0 ↔ 0,96 på 4 s. */
.circle-breathe { animation: circle-breathe 4s cubic-bezier(.42,0,.58,1) infinite alternate; }
@keyframes circle-breathe { from { transform: scale(1); } to { transform: scale(.96); } }
textarea:focus-visible, input:focus-visible { outline: none; }
