/* Served as api/index.php?action=asset, so font paths are relative to the api folder. */
/* Sizes use vmin so the layout scales with the screen. On the Galaxy Tab A9 in
   landscape (about 1000 x 600 CSS px) 1vmin is roughly 6px. */
@font-face { font-family: 'Atkinson Hyperlegible'; font-weight: 400; src: url(../fonts/ah-400.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Atkinson Hyperlegible'; font-weight: 700; src: url(../fonts/ah-700.woff2) format('woff2'); font-display: swap; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #0B1020; color: #fff;
  font-family: 'Atkinson Hyperlegible', system-ui, sans-serif;
  user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none;
}
.screen { position: fixed; inset: 0; display: none; flex-direction: column; gap: 3vmin; padding: 4vmin; }
.screen.on { display: flex; }

button {
  font: inherit; font-weight: 700; border: 0; border-radius: 4.5vmin; margin: 0; padding: 0;
  display: flex; align-items: center; justify-content: center; gap: 3vmin; color: #0B1020; cursor: pointer;
}
button:active, button.pressed { transform: scale(.97); filter: brightness(1.15); }
button svg { width: 12vmin; height: 12vmin; flex: none; }
.b-home { background: #2A3350; color: #fff; border: .7vmin solid #fff; font-size: 8.7vmin; }
.b-play { background: #FFC533; font-size: 10.6vmin; }
.b-play svg { width: 14vmin; height: 14vmin; }
.b-play.stop { background: #FF8A7A; }
.b-play #ic-stop, .b-play.stop #ic-play { display: none; }
.b-play.stop #ic-stop { display: block; }
.b-next { background: #8FD3FF; font-size: 8.7vmin; }
.off { opacity: .3; pointer-events: none; }

/* Home */
header { display: flex; justify-content: space-between; align-items: baseline; gap: 3vmin; }
#hello { font-size: 8.5vmin; font-weight: 700; }
#when { font-size: 6.3vmin; color: #D5DBEE; }
.tiles { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 3.5vmin; }
.tile { position: relative; font-size: 10vmin; gap: 4vmin; }
.tile svg { width: 18vmin; height: 18vmin; }
.t-music { background: #FFC533; } .t-photos { background: #8FD3FF; }
.t-messages { background: #9BE3A8; } .t-stories { background: #E3B8FF; }
.badge { position: absolute; top: 2vmin; right: 2vmin; background: #0B1020; color: #fff; font-size: 5vmin; padding: 1vmin 3vmin; border-radius: 99vmin; }
.badge[hidden] { display: none; }
#ver { position: absolute; left: 4vmin; bottom: .6vmin; font-size: 2vmin; color: #8A93AD; }

#newmsg { flex: none; height: 19vmin; background: #9BE3A8; font-size: 8vmin; border: .9vmin solid #fff; animation: glow 2.4s ease-in-out infinite; }
#newmsg[hidden] { display: none; }
#newmsg svg { width: 11vmin; height: 11vmin; }
@keyframes glow { 50% { border-color: #0B1020; } }

/* Resting photo frame: shown after a few minutes untouched. Touch anywhere to go Home. */
#frame { padding: 0; background: #000; }
#frameimg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity .8s; }
#framecap { position: absolute; left: 0; right: 0; bottom: 0; padding: 1.5vmin 4vmin; background: rgba(11, 16, 32, .8); text-align: center; font-size: 8vmin; font-weight: 700; }
#framecap:empty, #framenew:empty { display: none; }
#framenew { position: absolute; left: 0; right: 0; top: 0; padding: 1.5vmin 4vmin; background: #9BE3A8; color: #0B1020; text-align: center; font-size: 6.5vmin; font-weight: 700; }
#frameclock { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 2vmin; }
#frametime { font-size: 34vmin; font-weight: 700; line-height: 1; }
#frameday { font-size: 9vmin; color: #D5DBEE; }
#frame.clock #frameclock { display: flex; }
#frame.clock #frameimg, #frame.clock #framecap { display: none; }
#frame.night #framenew { display: none; }
#frame.night #frametime, #frame.night #frameday { color: #3A4157; }

/* Player: music, messages, stories */
#stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; gap: 6vmin; padding: 0 3vmin; }
#art { width: 36vmin; height: 36vmin; flex: none; border-radius: 5vmin; display: flex; align-items: center; justify-content: center; color: #0B1020; background: var(--tint, #FFC533); }
#art svg { width: 23vmin; height: 23vmin; }
#words { flex: 1; min-width: 0; max-height: 100%; overflow: hidden; display: flex; flex-direction: column; gap: 2.5vmin; }
#status { font-size: 6.3vmin; font-weight: 700; color: var(--tint, #FFC533); }
#line1 { font-size: 14vmin; font-weight: 700; line-height: 1.05; overflow-wrap: break-word; }
#line2 { font-size: 8.5vmin; color: #D5DBEE; overflow-wrap: break-word; }
#body { font-size: 9vmin; line-height: 1.2; overflow-wrap: break-word; white-space: pre-line; }
#status:empty, #line2:empty, #body:empty { display: none; }
#video { display: none; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.controls { height: 28vmin; flex: none; display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 3.3vmin; }

#player.mode-video { padding: 0; gap: 2.5vmin; }
.mode-video .controls { margin: 0 3vmin 3vmin; height: 26vmin; }
.mode-video #stage { padding: 0; }
.mode-video #video { display: block; }
.mode-video #art { display: none; }
.mode-video #words { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(11, 16, 32, .88); padding: 1.2vmin 4vmin; text-align: center; }
.mode-video #status { display: none; }
.mode-video #line1 { font-size: 8.5vmin; }

.mode-text #art { display: none; }
.mode-text #words { justify-content: center; }
.mode-text #line1 { font-size: 7vmin; font-weight: 400; color: #D5DBEE; }

/* Photos: the controls sit in a side column so the picture gets the full height
   of the screen. That suits upright photos and is also bigger for ordinary 4:3 ones. */
#photos { flex-direction: row; padding: 0; gap: 0; }
#photowrap { flex: 1; min-width: 0; min-height: 0; position: relative; background: #000; }
#photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
#photoempty { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; font-size: 10vmin; font-weight: 700; }
.side { width: 27vw; flex: none; display: flex; flex-direction: column; gap: 3vmin; padding: 3vmin; }
.side button { height: 25vmin; flex: none; font-size: 7.5vmin; gap: 2vmin; }
.side button svg { width: 10vmin; height: 10vmin; }
#capbox { order: -1; flex: 1; min-height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; text-align: center; }
#caption { max-width: 100%; font-size: 10vmin; font-weight: 700; line-height: 1.1; overflow-wrap: break-word; }

/* Settings: for family, opened by holding the faint cog on Home */
#when { margin-left: auto; }
#cog { flex: none; align-self: center; width: 9vmin; height: 9vmin; padding: 1.6vmin; margin: -1vmin -1vmin -1vmin 0; color: #3A4566; }
#cog.held { color: #8FD3FF; }
#cog svg { width: 100%; height: 100%; display: block; }
#settings { overflow-y: auto; touch-action: pan-y; user-select: text; padding: 20px; }
.setwrap { width: min(100%, 860px); margin: 0 auto; display: flex; flex-direction: column; gap: 18px; padding-bottom: 30px; }
.sethead { display: flex; justify-content: space-between; align-items: center; }
.sethead h1 { margin: 0; font-size: 32px; }
#settings button { font-size: 20px; padding: 12px 18px; border-radius: 12px; gap: 8px; touch-action: pan-y; }
.setrow { display: flex; flex-direction: column; gap: 8px; font-size: 20px; }
.setrow > span { font-weight: 700; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button, #set-test { background: #2A3350; color: #fff; border: 2px solid #8A93AD; font-weight: 400; }
.seg button.on { background: #8FD3FF; color: #0B1020; border-color: #8FD3FF; font-weight: 700; }
#settings input, #settings select { font: inherit; font-size: 20px; padding: 12px; border-radius: 12px; border: 2px solid #fff; background: #fff; color: #0B1020; max-width: 100%; }
.voicerow { display: flex; gap: 8px; flex-wrap: wrap; }
.voicerow select { flex: 1 1 260px; min-width: 0; }
.sethelp { margin: 0; font-size: 17px; line-height: 1.35; color: #D5DBEE; }

/* Family set-up (used once, by a family member) */
#setup { align-items: center; justify-content: center; user-select: text; }
#setupform { width: min(90vw, 560px); display: flex; flex-direction: column; gap: 18px; }
#setupform h1 { margin: 0; font-size: 36px; }
#setupform p { margin: 0; font-size: 22px; line-height: 1.35; }
#setupform input { font: inherit; font-size: 28px; padding: 14px; border-radius: 12px; border: 3px solid #fff; background: #fff; color: #0B1020; }
#setupform button { font-size: 26px; padding: 16px; border-radius: 14px; border-width: 3px; }

/* If the tablet is held upright */
@media (orientation: portrait) {
  .tiles { grid-template-columns: 1fr; grid-template-rows: repeat(4, 1fr); }
  #stage { flex-direction: column; justify-content: center; text-align: center; }
  #words { flex: 0 1 auto; width: 100%; }
  .controls button { flex-direction: column; gap: 1vmin; font-size: 7.5vmin; }
  #photos { flex-direction: column; }
  .side { width: auto; height: 31vmin; flex-direction: row; }
  .side button { width: 29vw; height: auto; flex-direction: column; gap: 1vmin; }
  #capbox { order: 0; }
  #caption { font-size: 8vmin; }
}
