/* DebateCraft on a phone, and inside WeChat's in-app browser.

   Linked after theme.css on the round page, and on the home and login pages
   for one rule only: the 16 px form fields of part 3, without which an iPhone
   zooms the page when a field is tapped (every other selector here names
   something only the round page has). Part 1 styles the few elements the
   recorder script adds; they exist on every screen but are hidden until they
   have something to say. Parts 2 to 6 apply only to a phone-sized touch screen
   (up to 480 px wide, a finger for a pointer) and leave every other layout as
   it was. No script depends on a selector in this file; the recorder script in
   round.html uses the same media query to decide where the bottom bar is shown
   and where the 3D chamber starts switched off, so change the two together.

   Rules that have to beat the stylesheets the scripts add later (chamber.css,
   preflight.css, manage.css, judges.css) are prefixed with "body", as in
   theme.css.

   Contents
     1  Any screen          3  Recorder            5  Chamber without 3D
     2  Bottom bar          4  Readiness lights    6  Report and recordings */

/* ---- 1. Any screen ------------------------------------------------------- */
/* The tip for WeChat's in-app browser sits on top of the recorder card. */
.wechat-tip { display: flex; align-items: flex-start; gap: .7rem; margin: .8rem 0 0; padding: .7rem .85rem; border: 1px solid var(--lapis-line); border-radius: var(--radius-sm); background: var(--lapis-tint); color: var(--ink-soft); font-size: .88rem; line-height: 1.6; }
.wechat-tip span { flex: 1 1 auto; min-width: 0; }
.wechat-tip button { flex: none; min-height: 2.25rem; padding: 0 .8rem; font-size: .86rem; }

/* The caption box also holds the text of the speech that was just saved, once it exists. */
.caption[data-captions="off"]:empty::before { content: "这台服务器不出实时字幕。讲完并保存后，文字才会出现在这里。"; }
.caption .caption-head { display: block; color: var(--muted); font-size: .86rem; font-weight: 600; }
.caption .caption-text { display: block; margin-top: .3rem; }
.caption[data-shows="text"] { max-height: 18rem; }

/* The bottom bar belongs to the phone layout only (the script keeps it hidden elsewhere too). */
.phone-bar { display: none; }

@media (max-width: 480px) and (any-pointer: coarse) {
	/* ---- 2. Bottom bar ----------------------------------------------------- */
	/* The two actions of a speech stay under the thumb wherever the page is
	   scrolled. They mirror the real buttons, which then need not be shown twice. */
	.phone-bar {
		position: fixed; z-index: 44; left: 0; right: 0; bottom: 0;
		display: flex; align-items: center; gap: .55rem;
		padding: .55rem .75rem max(.55rem, env(safe-area-inset-bottom));
		border-top: 1px solid var(--hairline); background: rgba(250, 247, 240, .97);
		box-shadow: 0 -10px 24px -18px rgba(10, 23, 54, .55);
	}
	.phone-bar .phone-clock { flex: none; min-width: 3.9rem; color: var(--lapis-deep); font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; text-align: center; }
	.phone-bar button { flex: 1 1 0; min-width: 0; min-height: 3.25rem; padding: 0 .5rem; border-radius: 12px; font-size: 1.02rem; font-weight: 650; white-space: nowrap; touch-action: manipulation; }
	.phone-bar #phoneRecBtn { border-color: var(--lapis-strong); color: #fff; background: linear-gradient(180deg, #2a4f93 0%, var(--lapis) 55%, #193669 100%); }
	.phone-bar #phoneRecBtn.rec-on, .phone-bar #phoneRecBtn.rec-on:disabled { opacity: 1; border-color: #a02d21; color: #fff; background: linear-gradient(180deg, #d24a3b, var(--danger)); }
	.phone-bar #phoneStopBtn:not(:disabled) { border-color: var(--lapis-deep); background: var(--lapis-deep); color: #fff; }
	body.has-phone-bar main { padding-bottom: calc(6rem + env(safe-area-inset-bottom)); }
	body.has-phone-bar .rec-controls > #recBtn, body.has-phone-bar .rec-controls > #stopBtn { display: none; }

	/* ---- 3. Recorder ------------------------------------------------------- */
	/* iOS zooms the whole page when a focused field is set smaller than 16 px.
	   This has to hold against every sheet, including those loaded later, and it
	   is not tied to the round page: any page that links this file gets it. */
	select, textarea, input:not([type="checkbox"]):not([type="radio"]):not([type="file"]) { font-size: 16px !important; }
	.page-round h1 { font-size: 1.3rem; }
	.page-round .lede { font-size: .95rem; }
	.wechat-tip { margin-top: .7rem; font-size: .86rem; }

	/* One column in the order a speech needs: the clock and what the recorder
	   says first, then the text, then the set-once choices. The document order,
	   and with it the keyboard order, is unchanged. */
	#recorder { display: flex; flex-direction: column; padding: 1rem .9rem 1.1rem; }
	#recorder > * { min-width: 0; }
	#recorder > h2 { order: -20; font-size: 1.05rem; }
	#recorder > h2 + p { order: -19; font-size: .86rem; line-height: 1.55; }
	#recorder > #preflightPanel { order: -18; }
	#recorder > #recClock { order: -16; margin: .8rem 0 .3rem; padding: .7rem .9rem .75rem; }
	#recorder > #timerNotice { order: -15; margin: .1rem 0 0; font-size: .82rem; }
	#recorder > .rec-controls { order: -14; margin: .45rem 0 0; }
	#recorder > #localBackup { order: -13; }
	#recorder > #caption { order: -12; margin-top: .6rem; font-size: 1rem; }
	#recorder > #finishCountdown { order: -11; }
	/* Once a speech is saved, "finish the round" follows the text of that speech:
	   someone recording a single speech does not have to look for it. */
	#recorder:has(#chamberMount[data-speeches]:not([data-speeches=""])) > #finishRoundForm { order: -11; margin: .7rem 0 0; padding-top: 0; border-top: 0; }
	#recorder > .rec-setup { order: -10; grid-template-columns: 6.5rem minmax(0, 1fr); gap: .65rem .7rem; margin: 1rem 0 .3rem; }
	#recorder > .rec-setup > label[for="role"] { grid-column: 1 / -1; }
	#recorder > .rec-setup input, #recorder > .rec-setup select { min-height: 2.9rem; }
	#recorder > #seatOrder { order: -9; font-size: .8rem; }
	#recorder > #chamberPanel { order: -8; }
	#recorder > .rec-mic-check { order: -7; }
	#recorder > .rec-mic-check button { min-height: 2.75rem; }
	#recorder > #micInput { order: -6; }
	#recorder > #micWarn { order: -5; }
	#recorder > .poi-live { order: -4; }
	#recorder > .poi-live button, #recorder > .poi-live input { min-height: 2.75rem; }
	#recorder > .rec-hint:not([id]) { order: -3; }
	.rec-clock .countdown { font-size: 2.9rem; }
	.rec-controls .rec-choice button { flex: 1 1 8rem; min-height: 2.9rem; }
	.rec-backup button, .rec-finish button, .recovery-row button { min-height: 2.75rem; }
	.rec-backup a { display: inline-flex; align-items: center; min-height: 2.75rem; }
	.recovery-row select { min-height: 2.75rem; }
	.recovery-row a { display: inline-flex; align-items: center; min-height: 2.75rem; padding: 0 .35rem; }
	#finishRoundBtn { min-height: 3rem; }
	.rec-alarm { top: calc(var(--bar-h) + .4rem); width: calc(100vw - 1.2rem); padding: .7rem .9rem; font-size: 1rem; }

	/* ---- 4. Readiness lights ----------------------------------------------- */
	/* Folded into the one-line summary; a tap on it shows the lights. What blocks
	   a recording is still spelled out without being asked (the detail lines). */
	body.page-round #preflightPanel { margin-top: .7rem; padding: .5rem .7rem; }
	body.page-round #preflightPanel .pf-head { position: relative; min-height: 2rem; padding-right: 1.7rem; align-items: center; cursor: pointer; }
	body.page-round #preflightPanel .pf-summary { flex: 1 1 auto; min-width: 0; }
	body.page-round #preflightPanel .pf-head::after { content: ""; position: absolute; right: .35rem; top: .55rem; width: .5rem; height: .5rem; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); }
	body.page-round #preflightPanel[data-open="true"] .pf-head::after { top: .8rem; transform: rotate(-135deg); }
	body.page-round #preflightPanel:not([data-open="true"]) .pf-row,
	body.page-round #preflightPanel:not([data-open="true"]) .pf-time,
	body.page-round #preflightPanel:not([data-open="true"]) .pf-recheck { display: none; }
	body.page-round #preflightPanel:not([data-open="true"]) .pf-head { flex-wrap: nowrap; }
	body.page-round #preflightPanel[data-open="true"] .pf-summary { flex-basis: calc(100% - 2.2rem); }
	body.page-round #preflightPanel .pf-light { min-height: 2.25rem; }
	body.page-round #preflightPanel .pf-recheck { min-height: 2.25rem; }

	/* ---- 5. Chamber without 3D --------------------------------------------- */
	/* On a phone the 3D scene starts switched off (the recorder script sets that
	   default). Its seat buttons, its notices and its one-line banner stay; the
	   stage shrinks to that banner. The switch in the chamber's bar turns 3D on. */
	body .chamber { margin: .9rem 0 .2rem; }
	body .chamber .chamber-bar button { min-height: 2.5rem; padding: 0 .9rem; font-size: .84rem; }
	body .chamber[data-mode="off"] .chamber-hint, body .chamber[data-mode="off"] .chamber-mirror { display: none; }
	body .chamber[data-mode="off"] .chamber-seats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
	body .chamber[data-mode="off"] .chamber-foot { display: flex; min-height: 0; }
	body .chamber[data-mode="off"] .chamber-stage { display: block; aspect-ratio: auto; margin-top: .45rem; overflow: visible; border-radius: 0; background: none; box-shadow: none; }
	body .chamber[data-mode="off"] .chamber-hud { position: static; }
	body .chamber[data-mode="off"] .chamber-hud > :not(.chamber-banner) { display: none; }
	body .chamber[data-mode="off"] .chamber-banner { position: static; width: auto; max-width: none; margin: 0; justify-content: flex-start; text-align: left; box-shadow: none; font-size: .86rem; }
	body .chamber[data-mode="off"] .chamber-banner[data-tone="hint"] { padding: 0; background: none; color: var(--muted); }
	body .chamber .chamber-banner button { min-height: 2.5rem; padding: 0 .9rem; }
	body .chamber .chamber-seat { min-height: 3rem; justify-content: center; }

	/* ---- 6. Report and recordings ------------------------------------------ */
	.analysis-tabs button { min-height: 2.75rem; }
	.analysis-toolbar { align-items: flex-start; }
	.handout-links a { min-height: 2.5rem; }
	.analysis-accordion > summary { padding: .7rem .9rem; }
	.analysis-accordion > :not(summary) { margin-left: .9rem; margin-right: .9rem; }
	.rp-ranking .ranking li { padding: .9rem 1rem 1rem .9rem; }
	.poi-toolbar button, .poi-row button, .poi-pagination button, .rp-status button { min-height: 2.75rem; }
	body .speech-manage button, body .manage-row button, body .manage-attach select, body .manage-row select { min-height: 2.75rem; }
	body .judge-panel .judge-button, body .judge-panel .judge-view { min-height: 2.75rem; }
	/* The recordings table becomes one block per speech: seat and state on a line,
	   then the file, its transcript and its actions at full width. */
	.saved-speeches { overflow-x: visible; }
	#speechTable, #speechTable tbody { display: block; width: auto; }
	#speechTable thead { display: none; }
	#speechTable tr.speech-row { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: .35rem .7rem; padding: .85rem 0; border-bottom: 1px solid var(--hairline); }
	#speechTable tr.speech-row:last-child { border-bottom: 0; }
	#speechTable tr.speech-row > td { display: block; width: auto; min-width: 0; padding: 0; border: 0; white-space: normal; }
	#speechTable tr.speech-row > td:first-child { grid-area: 1 / 1; }
	#speechTable tr.speech-row > td:last-child { grid-area: 1 / 2; }
	#speechTable tr.speech-row > td:nth-child(2) { grid-area: 2 / 1 / 3 / -1; }
	.transcript-preview:not([open]) { margin-left: 0; }
	.transcript-preview > summary { min-height: 2.5rem; }
}
