/** Shopify CDN: Minification failed

Line 16:0 Unexpected "{"
Line 16:1 Expected identifier but found "%"
Line 17:0 Unexpected "<"
Line 17:38 Unterminated string token
Line 19:12 Unexpected "{"
Line 19:21 Expected ":"
Line 19:53 Unexpected "1rem"
Line 23:2 Unterminated string token
Line 24:36 Unexpected "{"
Line 24:45 Expected ":"
... and 17 more hidden warnings

**/
{%- if section.settings.show_weather -%}
<div class="amnos-weather-bar" style="
  text-align: center;
  padding: {{ section.settings.padding_vertical }}px 1rem;
  font-size: 1.0rem;
  letter-spacing: 0.06em;
  opacity: 0.85;
">
  <div style="margin-bottom: 2px;">{{ section.settings.label_text }}</div>
  <div>
    <span id="amnos-temp">--</span>℃
    <span style="margin: 0 0.4em; opacity: 0.4;">／</span>
    湿度 <span id="amnos-hum">--</span>%
  </div>

  {%- if section.settings.show_comment and section.settings.comment_text != blank -%}
    <div style="font-size:0.92rem; margin-top:4px; opacity:0.65;">
      {{ section.settings.comment_text }}
    </div>
  {%- endif -%}

  {% render 'climate-comment',
    climate_mode: section.settings.climate_mode,
    manual_comment: section.settings.manual_climate_comment,
    system_active: section.settings.system_active,
    system_comment: section.settings.system_climate_comment,
    system_priority: section.settings.system_priority
  %}

</div>

<script>
(function() {
  fetch('https://api.open-meteo.com/v1/forecast?latitude=35.7547&longitude=139.5353&current=temperature_2m,relative_humidity_2m&timezone=Asia%2FTokyo')
    .then(function(r) { return r.json(); })
    .then(function(data) {
      var c = data.current;
      var tempEl = document.getElementById('amnos-temp');
      var humEl  = document.getElementById('amnos-hum');
      if (tempEl) tempEl.textContent = Math.round(c.temperature_2m);
      if (humEl)  humEl.textContent  = c.relative_humidity_2m;

      var commentEl = document.getElementById('amnos-climate-comment');
      if (commentEl) {
        commentEl.dataset.temp     = c.temperature_2m;
        commentEl.dataset.humidity = c.relative_humidity_2m;
        if (typeof amnosClimateComment === 'function') {
          amnosClimateComment();
        }
      }
    });
})();
</script>
{%- endif -%}

{% schema %}
{
  "name": "今日の空の風景",
  "settings": [
    {
      "type": "checkbox",
      "id": "show_weather",
      "label": "表示する",
      "default": true
    },
    {
      "type": "text",
      "id": "label_text",
      "label": "見出しテキスト",
      "default": "今日の空の風景"
    },
    {
      "type": "checkbox",
      "id": "show_comment",
      "label": "コメントを表示する（第2段階）",
      "default": false
    },
    {
      "type": "textarea",
      "id": "comment_text",
      "label": "コメント文",
      "placeholder": "湿度が高い日は、布を広げてから裁断すると扱いやすいことがあります。"
    },
    {
      "type": "range",
      "id": "padding_vertical",
      "min": 2,
      "max": 16,
      "step": 2,
      "unit": "px",
      "label": "上下の余白",
      "default": 6
    },
    {
      "type": "select",
      "id": "climate_mode",
      "label": "気候コメントモード",
      "options": [
        { "value": "auto", "label": "自動（気候連動）" },
        { "value": "manual", "label": "手動（固定コメント）" }
      ],
      "default": "auto"
    },
    {
      "type": "textarea",
      "id": "manual_climate_comment",
      "label": "手動コメント（手動モード時に表示）",
      "placeholder": "例：梅雨の季節、ゆっくりと手を動かす時間を。"
    },
    {
      "type": "checkbox",
      "id": "system_active",
      "label": "🚨 緊急モード（systemレイヤー）を有効にする",
      "default": false
    },
    {
      "type": "select",
      "id": "system_priority",
      "label": "警戒レベル",
      "options": [
        { "value": "info", "label": "情報（info）" },
        { "value": "warning", "label": "警戒（warning）" },
        { "value": "critical", "label": "緊急（critical）" }
      ],
      "default": "warning"
    },
    {
      "type": "textarea",
      "id": "system_climate_comment",
      "label": "緊急コメント（systemモード時に強制表示）",
      "placeholder": "例：台風接近中。無理のないご来店をお願いいたします。"
    }
  ],
  "presets": [
    { "name": "今日の空の風景" }
  ]
}
{% endschema %}
